-1

I was just trying to use raw_input in a python program when I got this strange message.

The program:

message = input("Want to see something?")

The output:

'module' object has no attribute 'raw_input'

Any help would make me very happy.

8
  • 1
    Is that one line the entire program?
    – senshin
    Commented Jan 16, 2014 at 22:21
  • 1
    can you add your actual code?
    – Brad
    Commented Jan 16, 2014 at 22:21
  • Im only getting the error from one line.
    – Torkoal
    Commented Jan 16, 2014 at 22:21
  • 1
    @Conner Restart your interpreter and try that line again, then.
    – senshin
    Commented Jan 16, 2014 at 22:22
  • NameError: name 'raw_input' is not defined @senshin
    – Torkoal
    Commented Jan 16, 2014 at 22:23

1 Answer 1

6

It depends on your version of Python. If you're using Python 2, you should use raw_input:

>>> raw_input("Want to see something? ")
Want to see something? Yeah!
'Yeah!'

As in Python 3, you should use input:

>>> raw_input("Want to see something? ")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'raw_input' is not defined
>>> input("Want to see something? ")
Want to see something? Yeah!
'Yeah!'

As you can see in the documentation, both do the exact same thing, just the name changed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.