Data type: Lists & while


a Introduction to the datatype list.


  1. Discover the methods a list supports. Use the command dir([]) at the command line.
  2. Create a list with things available in your environment.
  3. Print some elements or all from your list.


The essential properties of a list are:

  • Square brackets - the external indicator if parts of list are used.
  • A list can accommodate a wide variety of object types, for example, Strings, numbers ...
  • She has a variety of methods to manage the list items.

For more information about lists, have a look at: Built-in Types

Repetition with while

With a while loop, you can reach the same results as with the for loop! A termination condition leads to the end of the loop or to a premature demolition.

L1 = []  # empty List
L2 = ['The', 'brave', 'tailor', 'hit', 7, 'on', 'a', 'string']
print(L2[0], L2[1], L2[2], L2[3], L2[4], L2[5], L2[6], L2[7])
i = 0
while i < len(L2):
    i = i + 1           # The variable i must Modify the value,
                        # Otherwise it will loop indefinitely !!


With the slicing operator further sub output can be realized.

See also: Slicing