Learn
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
letters
. - Then, we add the string
'd'
to the end of theletters
list. - Next, we print out
4
, the length of theletters
list. - Finally, we print out
['a', 'b', 'c', 'd']
.
Instructions
1.
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?)
Then, set list_length
equal to the length of the suitcase
list.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.