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?
The input function is used only in Python 2.The raw_input() function is similar to input() function in Python 3. x. Developers are recommended to use raw_input function in Python 2.
There are two functions that can be used to read data or input from the user in python: raw_input() and input(). The results can be stored into a variable. raw_input() – It reads the input or command and returns a string. input() – Reads the input and returns a python type like list, tuple, int, etc.
The NameError: name 'raw_input' is not defined occurs when you try to call the raw_input() function using Python major version 3. You can only use raw_input() in Python 2. To solve this error, replace all instances of raw_input() with the input() function in your program.
Starting with Python 3, raw_input()
was renamed to input()
.
From What’s New In Python 3.0, Builtins section second item.
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: "))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With