UnicodeDecodeError in ex. 15


15 Formateo de strings con %, parte 2

Error message:
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)

I expected that the code was going to work properly, as I am doing exactly what was done in the previous exercise? So what is the problem here?

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)


Okay. I just didn't understand that the raw_input had to be replaced in the code, i.e. nombre = "XX", mision = "YY", color = "Blue"


certain characters you use (¿, á ó) seem to cause problems. Recommendation: don't use them

no, raw_input allows you to prompt the user for input, so when prompted (after removing the characters raw_input can't handle) you can type your input


In the Spanish version those letters were included in the string, but yes I agree that it is probably what caused the problem.
However, I was allowed to continue when replacing the raw_outputs.


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