Traceback (most recent call last): File "<input>", line 1, in <module> NameError: name is not defined

Answered

Hi all,

I am new to Python.

I try to run a simple code:

name = input()
print(f"Hello. {name}")

SInce yesterday I have tried to:

1. reinstall the program;

2. install an older version.

3. run the recovery windows assistance and reset my settings to the default one.

4. make an exception in Windows Defender and disable the defender completely.

The issue is still present. 

Could you please help me with this?

Thank you

 

 

 

0
5 comments

You haven't executed the code, you just opened Python Console.

Either run your file (right-click it and choose Run...) or copy the code to the Python Console and run it there.

2

Hi,

Apparently you use Python 2, right?

If so, you should use raw_input() instead of input()

1

Hi Sergey,

I get the same error and the version is 3.7.

 

 

 

0

Thank you! Since yesterday I have put so many efforts trying to solve something that works as intended.

Your solution worked like a charm.

0

Hi,

I found another solution to the problem:

 

1) In PyCharm, go to menu: Run\Debug...

2) In window "Debug", click on "Edit Configurations..."

3) In the next window, find the option: "Run with Python Console" and check the checkbox.

4) Click on button "Apply" and button "Close".

5) Run the program. (Program will run in Python Console).

0

Please sign in to leave a comment.