Quick question 10/19


#1

I got the code correct and passed this segment but my code doesn't print out what I expected it to.

hobbies = []
for x in range(3):
hobby = raw_input("Enter a hobby")
hobbies.append(hobby)
print(hobbies)

If I input: x, y, z for instance the output is: [u'x', u'y', u'z']. Where did the "u" come from?


#2

This may very possibly be a bug.... You may want to report this!


#3

Letter u indicates that the text is written in Unicode.


#4

You've also got quotes and brackets in that print, those aren't part of the data itself either.

What you are printing is a list, you'd be formatting in some way when showing it to an end user, for example you could put a newline between each string and then print the result, you'd get:

x
y
z

Unicode strings are also strings, and they are the default strings in Python3.


#5

codecademy learning takes place not on Python 3. in python 3 no function raw_input ()


#6

Yeah, raw_input was renamed to input, it's the very same function I think. The old input was removed? Because it was a bit weird and because it's equivalent to eval(input()) so if somebody wants weird they can just do that. (You have to agree that it's pretty weird to execute whatever the user enters as input, at least for a function called just "input")

Just so I don't get someone confused, I'll add:

Python2, use raw_input, avoid input
Python3, use input

Same function, but renamed.