input() is a built-in Python function for getting text from the user. It displays a prompt, reads a line typed at the keyboard, and returns that line as a string. section 4.3.1
Use input() as the input step in a larger program:
- Pass a prompt such as "What is your name? ". section 4.3.1
- Store the returned text in a variable. section 4.3.1
- Convert the string when later processing needs a number, using int(input(...)). section 4.4
Reading an age
age = int(input("Enter your age: ")) asks for text, converts it to an integer, and stores it in age. Conditional statements can then use that value to choose a message. section 4.4
>>> name = input("What is your name? ")
What is your name? Dan
>>> name
'Dan'
See the interactive name example: input() receives typed text, and print() displays a greeting using the stored value. section 4.3.1






