How do I use raw_input in Python 3


Question

import sys
print(sys.platform)
print(2**100)
raw_input()

I am using Python 3.1 and can't get the raw_input to "freeze" the dos pop-up. The book I'm reading is for Python 2.5 and I'm using Python 3.1

What should I do to fix this?

1
497
12/20/2018 9:42:16 AM

Accepted Answer

raw_input() was renamed to input()

From What’s New In Python 3.0.

928
7/27/2019 8:59:25 AM

This works in Python 3.x and 2.x:

# Fix Python 2.x.
try: input = raw_input
except NameError: pass
print("Hi " + input("Say something: "))

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon