0
Name 'x' is not defined
user_name = input("Input name: ") print("Hello" + user_name + "How are u ?") Output: NameError: name 'x' is not defined
10 Antworten
+ 6
Yeah, it's a problem of 2.7 python version.
I could find something useful.
Hope it helps you
https://stackoverflow.com/questions/21122540/input-error-nameerror-name-is-not-defined
+ 3
Try this
may be you have not pasted complete code may be u have using x variable anywhere in prpgram which is not defined
user_name = input("Input name: ")
print("Hello" + user_name + "How are u ?")
+ 1
It's working fine on sololearn:
https://code.sololearn.com/cSqcrMdEm8bk/?ref=app
Can you please give a screenshot ?
+ 1
The future is now thanks to science[LESS ACTIVE] my version of python on linux js 2.7.18 mby is this problem i'll go to update and try again
0
Nope same error again, iam writing code on linux kali with sublime code editor and run program with terminator A.S.
0
Simba i put in input my name but i write on this post x, x = my name
0
be sure you're executing the correct file. Open a terminal, navigate to the folder containing the file you created and type:
python "filename.py"
(where filename.py is the file you created)
ps: if your kali isn't that old you could use python3. It is installed by default but instead of python you must type python3 as command
0
Cristian Estevez thanks i use terminal by writing comand python, but my version of py is 2. X . X and i trying to download and upgrade and i cant but i try command puthon3 --version and i saw python 3.9.6 i mean and i use python3 then file, thanks for asking and my english im from serbia 🖐
0
actually i just remembered. python2 doesn't use parenthesis for the print statements. so that was the error. Yuo have to configure sublime to run python3 or just do it on the terminal.
0
Cristian Estevez thank you very much