9. Python Lists and Dictionaries 4. Late Arrivals & List Length


#1

Lesson:
https://www.codecademy.com/courses/python-beginner-en-pwmb1/1/1?curriculum_id=4f89dab3d788890003000096

Been stuck on this one for quite a while. Here's my code:

suitcase = []
suitcase = ["clothes", "meds", "toothbrush", "iPod"] 
suitcase.append("sunglasses")
# Your code here!
suitcase.append("bathing suit")
suitcase.append("sunscreen")
suitcase.append("camera")

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

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

each time I submit it gives me the same error message: "Oops, try again. Did you remember to append() three items to suitcase?". The console prints out the proper results just fine. I'll post that here as well:

"
There are 8 items in the suitcase.
['clothes', 'meds', 'toothbrush', 'iPod', 'sunglasses', 'bathing suit', 'sunscreen', 'camera']
None
"

I've been trying to work through this lesson for a while, but I'm stumped. I've checked the forums and archived posts but have not found a solution. A few people in other posts suggested that this might be browser related, but I've run the test on Internet Explorer and Chrome.

I'm not sure what I'm doing wrong, so if someone could shed some light on why I'm receiving this error, I would greatly appreciate it.


#2

On line 1 you have suitcase equal to an empty list and then on line 2 you have suitcase with four items in it. Line 2 is what is throwing it off. Just have suitcase that is set to equal an empty list.


#3

Hey thanks!

my code now looks like this and it went through just fine!

suitcase = []
suitcase.append("sunglasses")
# Your code here!
suitcase.append("bathing suit")
suitcase.append("sunscreen")
suitcase.append("camera")

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

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

#4

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