Tuesday, August 5, 2014

Day 122

Python at CodeCademy. Worked on Python tutorial 4 of 14, Python Lists and Dictionaries: Late Arrivals & List Length! Worked on adding items to the end of a list.

The code used:
suitcase = [] 
suitcase.append("sunglasses")

# Your code here!
suitcase.append('hat')
suitcase.append('shirt')
suitcase.append('shorts')

list_length = len(suitcase) # Set this to the length of suitcase

print "There are %d items in the suitcase." % (list_length)
print suitcase

The interaction for this code:
There are 4 items in the suitcase.
['sunglasses', 'hat', 'shirt', 'shorts']

No comments:

Post a Comment