15.string formatting with %, part 2. help needed


#1

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 %s, " \
"and your favorite color is %s %s %s." % (name, quest, color)

i answer the questions and get this error Traceback (most recent call last):
File "python", line 6, in
TypeError: not enough arguments for format string please help


#2

Have you read the error message? Do you agree with it? If not, in what way do you disagree?
Is there some other problem? If so, what is that other problem?


#3

ive read the error message but i dont understand what im typing wrong.


#4

It says that you aren't providing enough arguments for your format string.

How many values are you providing? How many values are required to fill up your placeholders? How many placeholders are there?

If it says it's the wrong amount, then you'd start counting, right? So what is the result of doing so?

When you write code you need to motivate why it should look like it does. So if you don't understand what's wrong about what you typed, then explaining your motivation for what you currently have would say a lot about where you're going wrong and is therefore something you'd want to include in your question.
Or if you can't motivate it then you've figured out that you need to read about how that something works, that means you've caught yourself just guessing and you then gotta find out more. If, then you don't know where to find that information, then that's the thing to ask about, because that were you couldn't get any further in approaching the problem.
See where I'm going with this? Try to identify what's stopping you from going forwards, and keep working on those things until there are no more options to explore and at that point explain what you've tried so far and what stops you.


#5

here are the instructions the page gives me
Now it's your turn! We have ___ in the code to show you what you need to change!

Inside the string, replace the three ___ with %s.
After the string but before the three variables, replace the final ___ with a %.
Hit Save & Submit Code.
Answer the questions in the console as they pop up! Type in your answer and hit Enter.

this is what i typed
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 %s, " \
"and your favorite color is %s %s %s." % (name, quest, color)

ive replaced the underscores and the console writes out the qestions but when i finish the last question the error pops up


#6

Sure?

But the error message is about your format string, not the instructions.

Where in your code is your format string? Let's not mention anything other than that.

If there's a string that has six placeholders and you only provide three values, then there's a deficit of three. Yes? So there are either too many placeholders or too few values provided. Or both. You would then start adding or removing values/placeholders to adjust into what you mean to be there.


#7

honestly i dont know but this is the code i typed

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 %s, " \
"and your favorite color is %s %s %s." % (name, quest, color)


#8

And you have an error message that says something about in what way that doesn't make sense


#9

this is the error that pops up in the console

Traceback (most recent call last):
File "python", line 6, in
TypeError: not enough arguments for format string


#10

Yes, and you would need to read it. Not me

I have been saying quite a lot about what it means to say though.


#11

thats the thing ive read it and cant work out where im going wrong


#12

If you're just trying to grab on to air then the best thing is probably if you go back to where you were standing on firm ground and was able to reason about what was going on.


#13

i appreciate you giving me this advice but i have been able to do all the other pages, but for some reason just cannot see where im going wrong on this specific page. it would be really help full if you would point out to me where im going wrong.


#14

Then going back to firm ground sounds like it's only as far back as reading the instructions more carefully and getting an expectation of what's supposed to happen

And also identify what you're missing. You kind of reply to that with "this is what I wrote" which entirely avoids thinking about what the problem is.

Questions about what's stopping you is what I'm looking for, and without them I'm not willing to go very far ahead of your reasoning (such as by pointing out the problem directly)

If you will, it's like I'm only able to answer yes/no questions, and you have to get to what you want by quizzing me on whatever you're missing to get to the end


#15

You don't need to write multiple %ss to get the second, third, ... arguments.
The first %s gets the first argument, the second gets the second, etc.

So replace %s %s with %s and %s %s %s with just %s also so that there is a grand total of three %ss in your string, then it will work


#16

I have this problem.

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 %s." % (name, quest, color)

Traceback (most recent call last):
File "python", line 1, in
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)

Help me , please.


#17

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


#19