For your hobby

hobbies = []

for i in range(3):
    hobby = raw_input("Hobby?")

print hobbies

This is the code I ran and I added three 'hobby' to the list 'hobbies', 'reading' , 'writing' and 'gaming'.

Hobby? reading
Hobby? writing
Hobby? gaming
[u'reading', u'writing', u'gaming']

Where did the 'u's come from?


It looks like raw_input() is returning Unicode encoded text, as denoted by the u. I was unable to reproduce this in the lab (Python 2.7.2) using FF.

Hobby? reading
Hobby? writing
Hobby? walking
['reading', 'writing', 'walking']

Please post a link to this exercise so we can test in that interface.

If you want to brute-force your way to normal strings,

... .append(str(hobby))

might do the trick. Just guessing, though, until we see the lesson.


Here is the link

... .append(str(hobby))

Worked, thanks.

I think it might be a bug.


Either way, the lesson passed without the correction. This will also work to produce normal strings:

... .append(hobby.encode("utf-8"))


thanks. that was helpful.


btw are there any courses on c or c++ or c# language?


Not on this site, as yet. It is often requested but there might be a lot involved in presenting that course, not the least of which could be expensive licensing.


Thanks for the information.


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