A Day at the Supermarket Exercise 1.2: This is KEY!


#1

Hi,

I look for the solution of the problem in the forum, and try to think what´s the problem, but i don´t understutn.

So I bring here to codes, the firs, that dosen´t work. The second, that works.

how can find the difference between this two?

It try reeding, and doing copy pase, but a dont find differences, but, the result is diferent.

https://www.codecademy.com/es/courses/python-beginner-es-mVOwe/0/2?curriculum_id=50fc7aab5fab3aa9c2002444#

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

Suppose to:
Print all items in the dictionary, but is not.


# This code dosen´t works:
webster = {
    "Cerdo hormiguero" : "La estrella de un popular programa infantil de caricaturas.",
    "Bee" : "El sonido que hace una cabra.",
    "Alfombra": "Va en el piso.",
    "Pizca": "Una cantidad pequeña."
}    

for x in webster:
    print webster[x]

# This code works:
webster = {
"Aardvark" : "A star of a popular children's cartoon show.",
"Baa" : "The sound a goat makes.",
"Carpet": "Goes on the floor.",
"Dab": "A small amount."
}


for key in webster:
    print webster[key]


#2

This line contains a Unicode character that is outside of the ordinal range for ASCII (max = 128). The fix is to include a unicode flag just before the opening quote of the string...

u"Una cantidad pequeña."

#3

Thks!!! I didn´t knew this, and i learn something new!


#4

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