input()
The built-in function that shows a prompt, waits for the user to type a line and press Enter, and returns what they typed as a string.
In more detail
input always returns a string, even when the user types digits, so convert with int() or float() before doing arithmetic. The prompt argument is printed without a newline, so end it with a space.
Example
age = int(input("Age: "))Related terms
- string — A sequence of characters, that is, a piece of text.
- type conversion — Turning a value of one type into another, such as the string "23" into the integer 23.
- print() — The built-in function that writes values to the screen, separated by spaces and followed by a newline.
Taught in
- Input, And Numbers Versus Digits — Hands-on Python: Complete Video Course & Book
- Function Parameters — Hands-on Python: Complete Video Course & Book
- Repeat Loops And Successive Modification — Hands-on Python: Complete Video Course & Book
- Entry Objects — Hands-on Python: Complete Video Course & Book
- Reading Error Messages — Hands-on Python: Complete Video Course & Book
- Print, Input And The Casts Between — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Fundamentals Sprint — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Handlers, args, raise And assert — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep