0

I've tried this simply code:

print ("Hello world")    
name=input("gimme name\n")
print(name)

And its return this:

Hello world
gimme name
Marcus
Traceback (most recent call last):
  File "./Desktop/python.py", line 2, in <module>
    name=input("gimme name\n")
  File "<string>", line 1, in <module>
NameError: name 'Marcus' is not defined

So. I know its not deffined i just want to define it. When I put in input place "Marcus" instead of Marcus, code working correct, but why my input is considered as a variable which cannot be found (obviously). I thought input is considered as a string and i need use int() or float() to change it.

kuba-end
  • 11
  • 7
  • 4
    You're trying to run this in a Python 2 interpreter. Either switch to a Python 3 interpreter, or use `raw_input` instead of `input`. – Carcigenicate Apr 23 '20 at 13:42
  • 3
    Does this answer your question? [input() error - NameError: name '...' is not defined](https://stackoverflow.com/questions/21122540/input-error-nameerror-name-is-not-defined) – Carcigenicate Apr 23 '20 at 13:43
  • Thank you Carcigenicate python3 ./Desktop/python.py instead of python ./Desktop/python.py solved problem, Im just new linux user – kuba-end Apr 23 '20 at 13:53

0 Answers0