Strings in python


applicant = input("Enter the applicant's name: ")
print("Good bye")

I am getting the following error
Traceback (most recent call last):
File "python", line 1, in
File "", line 1, in
NameError: name 'zain' is not defined

Replace this line with your code.


Could you post your full code, please? :slight_smile:


@zainy02 ,

In Python 2, use the raw_input function instead of the input function. Codecademy offers Python 2 in its exercises.

In Python 3, use input.

In Python 2, the input function attempts to evaluate what the user enters, as a Python expression. Therefore, if you enter zain in response to the prompt, the interpreter looks for a variable named zain, and if it does not exist, you get ...

NameError: name 'zain' is not defined

In Python 2, the raw_input function returns a str.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.