close

[Solved] input() – Name: name ‘…’ is not defined

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error input() – Name: name ‘…’ is not defined in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How input() – Name: name ‘…’ is not defined Error Occurs?

Today I get the following error input() – Name: name ‘…’ is not defined in python.

How To Solve input() – Name: name ‘…’ is not defined Error ?

  1. How To Solve input() – Name: name '…' is not defined Error ?

    To Solve input() – Name: name '…' is not defined Error

  2. input() – Name: name '…' is not defined

Solution 1

You are running Python 2, not Python 3. For this to work in Python 2, use raw_input.

input_variable = raw_input ("Enter your name: ")
print ("your name is" + input_variable)

Solution 2

Since you are writing for Python 3.x, you’ll want to begin your script with:

#!/usr/bin/env python3

If you use:

#!/usr/bin/env python

It will default to Python 2.x. These go on the first line of your script, if there is nothing that starts with #! (aka the shebang).

If your scripts just start with:

#! python

Then you can change it to:

#! python3

Although this shorter formatting is only recognized by a few programs, such as the launcher, so it is not the best choice.

The first two examples are much more widely used and will help ensure your code will work on any machine that has Python installed.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read