10.For your hobbies


The code runs normally,but I want to know why there is an "u" before the users in my output.What does that mean?Here is what happend in the interpreter:
Enter your name: hua
Enter your name: shao
Enter your name: jie
[u'hua', u'shao', u'jie']

hobbies = []

# Add your code below!
for i in range(3):
    user = raw_input("Enter your name: ")
print hobbies


something about codecademy causes raw_input stores the strings as unicode rather then string

so the u is of unicode, simply cast to a string:

str(raw_input("input: "))


Thank you,now I got it.


@stetim94's solution is probably the best way to handle this. However, here's an alternative that can also output a list of unicode or str objects ...



true, but in most cases raw_input would give you strings, not uni-code


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