For your hobbies


#1

This is my code:

hobbies = []

Add your code below!

for i in range(3):
hobby = raw_input("Enter a hobby: ")
hobbies.append(hobby)
print hobbies

And this is my output:

Enter a hobby: Soccer
Enter a hobby: Coding
Enter a hobby: Dancing
[u’Soccer’, u’Coding’, u’Dancing’]

Why does a ‘u’ precede every element in the list hobbies?


#2

cause raw_input stores the result as unicode:


https://docs.python.org/2/howto/unicode.html


#3

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