input()
Takes text input from the user via the keyboard.
Syntax
input(message)
Description
Prints an optional message to the screen and returns the line written by the user as TEXT (str). If you need a number, you must convert it using int() or float().
Parameters
| message(optional) | The prompt text to show the user. |
Returns
The line the user typed (str).
Example
Loading editor…
This language is for reference/learning only — copy the code and try it in your own environment.
Expected output
(After entering the name) Hello Alex
When to use?
For getting a name, number, or choice from the user in small console programs.
Common mistakes
- ⚠️ input() always returns text; for arithmetic, convert it like yas = int(input()).