2

Below is my code:

randomOne = int(str(raw_input('Enter the first number.')))
randomTwo = int(str(raw_input('Enter the second number.')))

I always get this error message:

Traceback (most recent call last):
    File "C:/Users/*****/Desktop/Pythons/randomNumberGenerator.py", line 5, in <module>
randomOne = int(str(raw_input('Enter the first number.')))
NameError: name 'raw_input' is not defined

I do not understand at all what is going on, if i could have some help?

3
  • 2
    what version are you on? raw_input was removed in Python 3, and its behavior switched to input. Commented Nov 27, 2013 at 18:56
  • As a side note: Why are you trying to call str on the result of raw_input? What are you expecting that to do? (In every version of Python that had raw_input, from 0.x to 2.7, it returns a str, so calling str on it will just make a copy.) Commented Nov 27, 2013 at 19:04
  • 1
    Meanwhile, if you're using Python 3.x, but using examples written for Python 2.x, you may want to at least skim What's New in Python 3.0, and bookmark it to search it whenever you have a problem like this. For example, if you search the page for raw_input, you'l find "PEP 3111: raw_input() was renamed to input()…" Commented Nov 27, 2013 at 19:06

1 Answer 1

7

If you are using python 3, it doesn't have raw_input, use input instead.

Sign up to request clarification or add additional context in comments.

1 Comment

that was more simple of a problem then i thought...*facepalm*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.