Home >Backend Development >Python Tutorial >Why Doesn't `raw_input()` Work in Python 3?
Redefining the 'raw_input' Function in Python 3
When attempting to utilize the 'raw_input()' function in Python 3, users often encounter an error indicating that the name is not defined. This is because 'raw_input()' has been renamed to 'input()' in Python 3 to enhance its functionality.
Renaming 'raw_input()' to 'input()' in Python 3
To address this issue, Python 3 introduced the 'input()' function as a replacement for 'raw_input()'. This change was documented in the official Python documentation, "What's New In Python 3.0," under the Builtins section.
By utilizing the 'input()' function, Python 3 programmers can read a line of input from the standard input, just as they would with 'raw_input()' in earlier Python versions. However, 'input()' provides added functionality by automatically converting the input into a Python string, eliminating the need for explicit typecasting.
The above is the detailed content of Why Doesn't `raw_input()` Work in Python 3?. For more information, please follow other related articles on the PHP Chinese website!