LOOPS_ for your hobbies


#1

ISSUE:
enter hobby GAME
enter hobby PYTHON
enter hobby ALOO
[u'GAME ', u'PYTHON', u'ALOO']
None

Why is it adding 'u' to beginning of each hobby name??

hobbies = []

Add your code below!

for i in range (3):
c=raw_input('enter hobby')
hobbies.append(c)
print hobbies


#2

codecademy stores the result of the prompt as unicode, not as string. so the u is of unicode

cast to string (str()) to get rid of the u


#3

I had the same question, changing my code to:

hobby = str(raw_input("What is your hobby?"))

got rid of the "u." Why has this condition not appeared in previous exercises?


#4

given the u only shows when you print the list, not when you print the user input directly or each item of the list


#5

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