4/9 Late Arrivals & List Length


#1

suitcase = ['hair', 'hat', 'ears'] 
suitcase.append("sunglasses")

# Your code here!
suitcase.append("shoes")
suitcase.append("socks")
suitcase.append("nose")




list_length = 7 # Set this to the length of suitcase

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

Message: Oops, try again. Did you remember to append() three items to suitcase?

What's wrong? All like in example and instruction ask.


#2

Not exactly you set the list_length var to 7 an integer when you were required to use the len() method to print out the length of your suitcase list.


#3

if i look at the default code of the exercise:

suitcase = [] 
suitcase.append("sunglasses")

# Your code here!




list_length = ________ # Set this to the length of suitcase

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

the suitcase is empty, only use append() to add items to the suitcase. @bandit is right, don't hard code the length of the list.


#4

Ok, whats wrong now?
3 items (and other) appended.

suitcase = []
suitcase.append("sunglasses")

Your code here!

suitcase.append("hair")
suitcase.append("hat")
suitcase.append("ears")
suitcase.append("shoes")
suitcase.append("socks")
suitcase.append("nose")

list_length = 7 # Set this to the length of suitcase

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

Message: Oops, try again. Did you remember to append() three items to suitcase?


#5

you appended 6:

suitcase.append("hair")
suitcase.append("hat")
suitcase.append("ears")
suitcase.append("shoes")
suitcase.append("socks")
suitcase.append("nose")

not three?


#6

Problem soleved.

Worked:

suitcase = []
suitcase.append("sunglasses")

Your code here!

suitcase.append("ears")
suitcase.append("finger")
suitcase.append("mouth")

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

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