Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am trying to use the raw_input from python program, but I am getting the strange message

This my code:

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

The message I am getting is:

'module' object has no attribute 'raw_input'

Any help would be appreciatable. 

1 Answer

0 votes
by (36.8k points)
edited by

Mainly it depends on the Python version. 

For Python 2 you can use raw_input:

raw_input("Want to see something? ")

Want to see something? Yeah!

'Yeah!'

For 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!'

If you are a beginner and want to know more about Data Science the do check out the Data Science course 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...