Forum Archive

Possible Bug with Pythonista

aidanharris

For some reason the following code does not work:

a=input('input something: \n')
print(a)

It produces the following error message even if I wrap the input in str()

NameError: name 'hello' is not defined

onionradish

That's correct behavior. input() attempts to parse whatever is entered as a direct Python statement. If you want user input, you probably want raw_input():

a=raw_input('input something: \n')
print(a)