Late Arrivals and List Length


#1



Oops, try again. Remember: len(list_name) will return the length of a list as an integer.


Why doesn't just inputting 4 work?


Replace this line with your code. 
suitcase = [] 
suitcase.append("sunglasses")

# Your code here!
suitcase.append("shirts")
suitcase.append("suit")
suitcase.append("sunscreen")



list_length = 4
# Set this to the length of suitcase

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


#2

Because the lesson asks us to use the len() function to query the list length. That is how it is done in a program. If we use literals then the list cannot be altered. Length is dynamic, just as the list is. It increases and decreases as the list grows and shrinks.


#3

Cool. Great explanation. Thanks for your help.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.