Weird character in hobbies array?


#1

When I print the hobbies array, I get the output:

Enter your activity: hi
Enter your activity: hi
Enter your activity: hi
[u'hi', u'hi', u'hi']
None

I'm wondering what the 'u' character exactly is and why it's there. Can anyone explain this to me?

My code is shown below: :slight_smile:


hobbies = []

Add your code below!

for activity in range(3):
hobby = raw_input("Enter your activity:")
hobbies.append(hobby)
activity +=1

print hobbies


#2

excuse the add your code below lol


#3

raw_input gives unicode encoding, you can read about it here

If you want to get rid of it, you can cast it to a string:

hobby = str(raw_input("Enter your activity:"))

#4

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