Hobby


#1

hobbies = []

Add your code below!

for i in range(3):
hobbies.append(raw_input(“hobby”))
print hobbies

If I input hi, hu, and ho
Why does it output
[u’hi’,u’hu’,u’ho’].
Why are there u’s?


#2

Hi @miko6448,

The following test reveals that the user input is stored within hobbies as unicode type objects …

print type(hobbies[0])

Output …

<type 'unicode'>

You can get nicer output as follows …

for hobby in hobbies:
  print hobby

That will convert each item to a str object for output purposes, which omits the u prefix.

See Wikipedia: Unicode.


#3

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