0

I had a problem while coding I tried to solve it by abstracting the non-problematic parts and making a new Pycharm project with only the problematic part so that I can see it more clearly but I still can't see any problems. I think it may be because of a software error but I am not sure

Here is the problematic part:

import sys
import os

User_Name=str(input("What is your name?"))
print (User_Name)

Here is the outcome:

What is your name? #X Traceback (most recent call last): File "C:/Users/USER/PycharmProjects/More_Complex_Projects/BLINDFOLDED.py", line 4, in User_Name=str(input("What is your name?")) File "", line 1, in NameError: name 'X' is not defined

Process finished with exit code 1

I expected it to print out the variable User_Name but it just gives an Name error

DxTx
  • 3,049
  • 3
  • 23
  • 34
3mr3Yenen
  • 3
  • 4

2 Answers2

1

After a bit of research :

Now what you have is 2.7 , therefore you should tend to use raw_input() rather than the input().

Try :

import sys
import os

User_Name=str(raw_input("What is your name?"))
print (User_Name)
Born Tbe Wasted
  • 610
  • 3
  • 13
1

Seems like you're using Python 2. In this case, you should use raw_input, which doesn't attempt to parse the inputted string and not input:

user_name = raw_input("What is your name?")
# Here -----^
Mureinik
  • 297,002
  • 52
  • 306
  • 350