What built-in Python function is used to get user input from the console?

The story behind the answer

The built-in Python function used to get user input from the console is input(). Calling input() pauses the program, displays an optional prompt, waits for the user to type a response, and returns that response as a string.

For example, name = input("What is your name? ") stores the typed text in name. Even if the user enters digits, input() still returns text, so arithmetic requires an explicit conversion such as int(input("Enter a number: ")). For decimal values, programmers commonly use float().

A frequent historical mix-up concerns Python 2. In Python 2, raw_input() performed the modern input() behavior, while input() attempted to evaluate the entered text as Python code. Python 3 unified the ordinary console-input behavior under input() and removed raw_input(). Functions such as get(), scan(), and read() are not Python’s standard built-in console-input function, though other languages and libraries may use similar names.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: