(10/19) Why am I getting a [u, "user Input"] EXAMPLE : [u'buffet', u'sumo']


hobbies = []

Add your code below!

for i in range(3):

Input = raw_input("Input your hobby:")


print hobbies


Don't do things like that...

Do it like this,

for i in range(3):
    hobbies.append(raw_input("Input your hobby:"))


Your code is better, but I am genuinely curious on why it added that 'u'.


It's a regular expression, that is a little too advanced for this course nor will they ever touch upon all the different things you can do with regular expressions in these course here.

Note: Regular Expressions are technically a mini-language.

EXAMPLE: This finds email@interweb.com addresses

import re

pattern = r"([\w\.-]+)@([\w\.-]+)(\.[\w\.]+)"
str = "Please contact info@here.com for assistance"

match = re.search(pattern, str)
if match:


Bit of an omega for me (over my head) but I still appreciate the explanation and help you have given. Thanks for your 'Input' :smiley:
Ill mark this as solved for now.


Hi @sonbot,

The 'u' in front of a string generally means that the string is in the unicode format.

As @zeziba said, it is beyond the introductory level that is taught here on Codecademy so I wouldn't worry myself with that for now :wink:

I just wanted to post the related Python Doc here just in case someone ends up looking up this thread for answers while searching the forum... :smile:


use str() like this:
hobbies.append(str(raw_input("write a hobby")))


I used a str as suggested and still could not enter the second hobby and still got the u before each of the hobbies - the second the same as the first!


Thank you for the suggestion to cut down the code!


Did you find the solution for this?


Compare the following two approaches for displaying the output. The second one uses a list comprehension to convert each of the items in hobbies to a str, which omits the u.

# display the hobbies list as is
print hobbies

# display each item in the hobbies list as a str
print [str(hobby) for hobby in hobbies]

Output …

[u'hiking', u'photography', u'programming']
['hiking', 'photography', 'programming']

List comprehensions are introduced later on in the Learn Python track in Advanced Topics in Python: Building Lists.



Sorry I stopped using CodeAcademy…


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