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

17th Jun 2021, 11:39 AM
Uroš Rakic
Uroš Rakic - avatar
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
17th Jun 2021, 12:30 PM
Simba
Simba - avatar
+ 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 ?")
17th Jun 2021, 11:44 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
It's working fine on sololearn: https://code.sololearn.com/cSqcrMdEm8bk/?ref=app Can you please give a screenshot ?
17th Jun 2021, 11:51 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 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
17th Jun 2021, 11:53 AM
Uroš Rakic
Uroš Rakic - avatar
0
Nope same error again, iam writing code on linux kali with sublime code editor and run program with terminator A.S.
17th Jun 2021, 11:50 AM
Uroš Rakic
Uroš Rakic - avatar
0
Simba i put in input my name but i write on this post x, x = my name
17th Jun 2021, 11:59 AM
Uroš Rakic
Uroš Rakic - avatar
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
18th Jun 2021, 7:08 PM
Cristian Estevez
Cristian Estevez - avatar
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 🖐
18th Jun 2021, 7:12 PM
Uroš Rakic
Uroš Rakic - avatar
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.
18th Jun 2021, 7:25 PM
Cristian Estevez
Cristian Estevez - avatar
0
Cristian Estevez thank you very much
18th Jun 2021, 7:27 PM
Uroš Rakic
Uroš Rakic - avatar