Lists - Learn Python 3 - Snakify

Lesson 7. Lists

1/26. Lists: why do we need them

Most of programs work not only with variables. They also use lists of variables. A program can handle an information about students by reading the list of students from the keyboard or from a file. A change in the number of students in a class must not require modification of the program source code.

We have already faced the task of processing elements of a sequence — for example, when finding the largest element of the sequence. But we haven't kept the whole sequence in computer's memory. However, in many situations it is necessary to keep the entire sequence, like if we had to print out all the elements of a sequence in ascending order ("sort a sequence").


Click "Run" to see what happens in output!

Primes = [2, 3, 5, 7, 11, 13]
Rainbow = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet']