Reputation: 31
I am writing a simple input and I keep getting an error. Fir example if I type in 'Eagle' it get name error eagle is not defined. Why is this?
print("The new word?")
newword = input()
Upvotes: 0
Views: 864
Reputation: 16753
Use raw_input
instead if you don't want to evaluate the expression supplied. By default python evaluates whatever you supply to input
as python expression, raising the name error.
newword = raw_input('the new word')
Otherwise, if you are meant on using input
, then you need to enclose your entry string in quotes. Then python would consider it a string eliminating the NameError. Supply 'Eagle'
instead of Eagle
. Moreover, its better to supply the prompt string in input parameters i.e.
newword = input('The new word')
#supply 'Eagle' (in quotes)
Upvotes: 1