1

I have this simple bit of code in visual studio using python

name = input("What is your name? ")

print (name)

However when I run it the string "What is your name" appears so I type in a name then the code breaks and a red line appears under the last bracket and i'm told

NameError was unhandled by user code

name 'John' is not defined

I have no idea why this is happening i'm following a tutorial

https://www.microsoftvirtualacademy.com/en-us/training-courses/introduction-to-programming-with-python-8360

Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176
Mirabel
  • 11
  • 1

1 Answers1

1

Use raw_input(), if you are using python2.x - input() in python2.x actually tries to evaluate the string you enter as a Python expression.

plamut
  • 3,085
  • 10
  • 29
  • 40