Why do my hobbies have a ‘u’ before them when I print them?


#1

Question

Why do my hobbies have a ‘u’ before them when I print them?

Answer

This happens because raw_input() returns a unicode string, and that’s all the u means. If you’re seeing some output like this: [u'knitting', u'biking', u'coding'], that’s totally normal. Python is intentionally letting you know that the output is unicode.
To “fix” this, we can convert our hobbies to strings as we append them, like this: hobbies.append(str(hobby)).


FAQ: Learn Python- Loops - For your hobbies