0

I'm using

Python 2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)] on win32

on Windows-7. The string-input function doesn't do well.

2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)] Python Type "help", "copyright", "credits" or "license" for more information.

name = input ("Please enter your name:")
Please enter your name:Othmar
Traceback (most recent call last):
  Python Shell, prompt 1, line 1
  File "<string>", line 1, in <module>
NameError: name 'Othmar' is not defined

I tried this in Eclipse, on CLI with Python-consoleprompt and on the IDE wing-101. It's all the same outcome.

What's wrong here?

olippuner
  • 394
  • 4
  • 16
  • In python 2, if you just want the user string, use `raw_input`. `input` tries to evaluate user input as a python expression. BTW, this is different in 3.x where `input` works like `raw_input` used to. – tdelaney Jan 21 '17 at 21:53
  • That's insane of python, but sounds like a very good explanation. Thanks. very much. Your answer guided me to http://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input-and-input-in-python3-x – olippuner Jan 21 '17 at 21:58

0 Answers0