Late Arrivals & List Length (4/14)


#1

suitcase.append(“sunglasses”, “undies”, “socks”, “flamingos”)

Hi guys, so I was doing the lesson stated in the title and I wrote the code wrong (above), I figured it out after reading the error message and fixed it (below)… I’m curious as to why the above code would not work though?
Cheers.

suitcase = []
suitcase.append(“sunglasses”)
suitcase.append(“undies”)
suitcase.append(“socks”)
suitcase.append(“flamingos”)

list_length = len(suitcase)

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


#2

the exercise validation is looking for multiply append keyword, and looking at the docs:

https://docs.python.org/2/tutorial/datastructures.html

.append() can only handle appending a single item.


#3

Hi thanks for your response. This docs.python.org page you linked, is this something I am supposed to be referring to while doing these lessons? This is the first time I’ve seen it.


#4

if you don’t understand a built-in function like .append() the docs are an excellent place to read about the function. Reading docs is something you will do a lot when you get developers job


#5

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