eTechtips

Tech Tips and Insights

Python: error when using the input() function

I was writing a basic guessing game and when I tried to take user input I was
getting the following:

Code:

guess = input()
d

Error:

Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
NameError: name 'd' is not defined

The problem is actually with the version of Python that I was using. If you
are using Python 2.x, you need to use the raw_input() function. And with 3.x
you can use the input() function.

Loading

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.