Skip to content

1.3.2 Getting User Input with input() ​

The input() function is used to receive input from the user during program execution.
It pauses the program and waits for the user to type a value.


How input() Works ​

When input() is called:

  • The program displays an optional prompt
  • The user enters text
  • The input is returned as a string

This behavior is consistent regardless of what the user types.


Input and Data Types ​

Because input() always returns a string:

  • Numeric input must be converted before calculations
  • Type conversion is often required

Understanding this behavior is critical for avoiding logic errors.


Common Use Cases ​

  • Asking for user information
  • Reading configuration values
  • Interactive scripts and tools

📌 Note:
Always consider type conversion when working with user input.