NameError: name 'raw_input' is not defined

Asked 1 years ago, Updated 1 years ago, 93 views

It worked well at school, but it doesn't work when I get home. It says raw_input is undefined, what's wrong?

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

Traceback (most recent call last): File "/Users/hoj/PycharmProjects/mine.py", line 1, in raw_input()

python nameerror

2022-09-22 22:13

1 Answers

This is because the Python version used at school/home is different.

I think I use 2.x at school and 3.x at home. raw_input() cannot be written in 3.x; you must write input().


2022-09-22 22:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.