Https://www.codecademy.com/courses/learn-python/lessons/strings--console-output/exercises/string-formatting-with--part--1?action=lesson_resume


#1

https://www.codecademy.com/courses/learn-python/lessons/strings--console-output/exercises/string-formatting-with--part--1?action=lesson_resume
Hi! ; despite writing the code properly , the error still exist , i can’t neither write the answers nor get to the next lesson , any help ?


#2

Can you try to post your code here? We can’t see what your code is by clicking the link


#3

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)


#4

The problem is a bit silly and I’m not sure if it was already explained in the course this far, but your print statement is acting up. You are missing the continuation mark \ (the backslash). It should go in between both lines of string.
Like this

"Ah, so your name is %s, your quest is %s, "
\
“and your favorite color is %s.”

Because otherwise Python thinks these are 2 separate strings and will apply the string substitution to them separately and therefore fail. The backslash will tell Python it’s one string of text. A other solution to this problem is putting all of the text within single quotation marks “” like this but without the \ backslash:

“Ah, so your name is %s, your quest is %s, and your favorite color is %s.”

Hope this is helpful.


#5

Be sure to enter something at each prompt (three inputs, in all), else the program will be waiting and will eventually timeout. Make sure to enter something, not just hit Enter.


#6

What is your name?What is your quest?What is your favorite color?Ah, so your name is SCT, your quest is if type(error) == ValueError:, and your favorite color is return "Make sure to use a lowercase “s” with %s. Python told us about the following error: " + str(error).
the same prb again can u try to write it here pls https://www.codecademy.com/courses/learn-python/lessons/strings--console-output/exercises/string-formatting-with--part--1?action=lesson_resume
i’m thinkin’ that the prb is from the website itself


#7

can u give me an example ?


#8

I tried just hitting enter without any input and it still worked. It is probably something with his code that is causing the traceback


#9
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)

This is my code that works. Don’t just copy paste it, but look at it and compare it to the code you have in your screen. If you see any difference change your code and run it and see if it works. If you spot a difference please let me know what it was. Remember to look very closely it can be in the details


#10

i coppied ur code ; past it there ; and yet , it doesn’t work , when i write my code on another online console it does , i really don’t know why


#11

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