Late Arrival and Lists - What is wrong?


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

suitcase = [] 

# Your code here!
suitcase.append('bathing suit')

list_length = 4 # Set this to the length of suitcase

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


use len() like the error message suggest, hard coding list_length like you did is considered bad practice. using len() will make your code more robust.

lets say you want to add another item to your suitcase, you might forgot to update list_length, if you would use len(), its done automatically. So your code is less prone to mistakes


Hi, i did list_length = len("suitcase") # because here we can put the length of suitcase for list_length
and if you put more "objets" in your suitcase the length can change.
print "There are %d items in the suitcase." % (list_length)

There are 4 items in the suitcase.


Codemaster55976 is right


The solution is pretty much in this topic? If it doesn't suit you, please make a new (linked) topic like stated in the guidelines and don't hijack an existing topic


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