A list doesn’t have to have a fixed length. You can add items to the end of a list any time you like!
letters = ['a', 'b', 'c'] letters.append('d') print len(letters) print letters
- In the above example, we first create a list called
- Then, we add the string
'd'to the end of the
- Next, we print out
4, the length of the
- Finally, we print out
['a', 'b', 'c', 'd'].
On lines 5, 6, and 7, append three more items to the
suitcase list, just like the second line of the example above. (Maybe bring a bathing suit?)
list_length equal to the length of the