4/9 lesson error


#1

so.... I'm back again, with another error. I really don't know why.
here's the code:

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

Your code here!

suitcase.append("tablet")
suitcase.append("phone")
suitcase.append("laptop")

list_length = 4 # Set this to the length of suitcase

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

I feel a bit stupid.


#2

Hello, @k-nox.
The %s is used to place a value into that exact position on a string.
There's no such thing as %4 so try changing that to %s and your code will work.

Best regards,
G4be.

Don't say such thing! This is coding, we're used to commit mistakes and LEARN from them!
You're doing a good job, buddy :slightly_smiling:


#3

and here is the damn error:

Traceback (most recent call last):
File "python", line 11, in
ValueError: unsupported format character ' ' (0x20) at index 12


#4

and now this one:

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


#5

man, i love computing. this is one good reason i started to learn coding.


#6

@k-nox: The problem is that the function len() returns the lenght of a list, dictionary, string and even tuples.
If you want to use lent() and get the size of your list and put into that string, you should do something like this:

str(len(listName))

Is it needed? No.
The lesson asked you to assign the value of the size of your list into list_lenght, all you have to do now is to :

print "Hey! Your list's lenght is %s !" % list_lenght

#7

yeah... i passed it. i forgot to print the length of suitcase. such stupid, me....


#8

It happens, Nox.
Don't worry so much about it!

Enjoy coding!

Best regards,
G4be


#9

thanks mate! you too!