Little help please?


#1

Some help with 15. String formatting with %, part 2 please?

The error I got: Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: not all arguments converted during string formatting.

Thanks,


#2

Could you copy your code in, please? How are we supposed to know where you did the error? :confused:


#3

Of course, sorry I'm new to this.

name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")

print "Ah, so your name is %s, your quest is %s, " \
"and your favorite color is." % (name, quest, color)


#4

you forgot one %s at the end, which was for the color :smiley:

"and your favorite color is %s."


#5

Ahhh, it goes inside the quotation marks, I see.

I was confused because on the template the ___ was outside the quotations, I had to put it inside.
Thanks for that :slightly_smiling:


#6

Okay news just in, I'm still getting an error.

Here's the code:

name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")

print "Ah, so your name is %s, your quest is %s, " \
"and your favorite color is %." (name, quest, color)

Here's the error:

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: 'str' object is not callable


#7

"and your favorite color is %s." %(name, quest, color)
the %s is like a placeholder, and the % at the end defines, what actually comes into those placeholders :slightly_smiling:


#8

Why don't the other strings have a percentage sign on all of them? Is it because the final one defines all the above %s variables?

Again, thanks a bunch :slightly_smiling:


#9

Hmm, you could say, that the last % only tells the programme, that the placeholder are going to be replaced.

You're welcome, I'm glad that I could help out :smiley:


#10

Makes so much sense when you explain it, thanks :smiley: