Custom String Formatting with % questions


#1



https://www.codecademy.com/en/courses/python-beginner-sRXwR/3/4?curriculum_id=4f89dab3d788890003000096

I've followed the same format as the exercise except tweaked the questions and response, but I still can't seem to get it to work.

This popped up:
Your code threw the following error: invalid syntax (python, line 3)


Replace this line with your code.


#2

Hi can you post your code?


#3

one = raw_input("What is your favorite Number?")
two = raw_input("What is your least Favorite Number?")
three = raw_input("How old are you?")

print "So your favorite number is %s, least favorite is %s."
"and you are %s years old" % (one, two, three)


#4

Hi its the string ...

look what you did

print "So your favorite number is %s, least favorite is %s." 
"and you are %s years old" % (one, two, three)

and How it should be

print "So your favorite number is %s, least favorite is %s." \
"and you are %s years old" % (one, two, three)

it's mssing the \ the end of the first line


#5

Got it! Thanks! But what does the \ do exactly?


#6

it's from Lesson: String Formatting with %, Part 2 in the Hint it says...

The \ character on line 5 is a continuation marker. It simply tells Python that line 5 continues onto line 6.


#7

hi, Can you help me? I don't look the error
nombre = raw_input("¿Cuál es tu nombre?")
mision = raw_input("¿Cuál es tu misión?")
color = raw_input("¿Cuál es tu color favorito?")

print "Ah, asi que tu nombre es %s, tu mision es %s," \
"y tu color favorito es %s." % (nombre, mision, color)


#8

HI when you begin your code should be like that

nombre = raw_input("Cual es tu nombre?")
mision = raw_input("Cual es tu mision?")
color = raw_input("Cual es tu color favorito?")

print "Ah, asi que tu nombre es ___, tu mision es ___, \
y tu color favorito es ___." ___ (nombre, mision, color)

but your code look like that

nombre = raw_input("¿Cuál es tu nombre?")
mision = raw_input("¿Cuál es tu misión?")
color = raw_input("¿Cuál es tu color favorito?")