10.For your hobbies


#1

https://www.codecademy.com/courses/learn-python/lessons/loops/exercises/for-your-hobbies?action=lesson_resume

Why does my code print out to the console:
Enter a hobby: jogging
Enter a hobby: swimming
Enter a hobby: video games
[u’jogging’, u’swimming’, u’video games’]

instead of:
Enter a hobby: jogging
Enter a hobby: swimming
Enter a hobby: video games
[‘jogging’, ‘swimming’, ‘video games’]
?

this is my code:



hobbies = []

# Add your code below!
for i in range(3):
  hobbies.append(raw_input('Enter a hobby: '))
print hobbies 



#2

because raw_input stores the result as unicode (u is of unicode), you can convert the input to string if you want to get rid of the u


#3

How does one do that? Convert the input to string?


#4

google: python convert to string

recommendation:

learn to do your own research, being able to find a solution is a valueable skill
the function required is already taught, this is why i put no effort into explaining the function you need


#5

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