Search⌘ K
AI Features

Input and Assign to Variable

Explore how to capture user input in Python using the input() function and assign that input to variables. Understand variable naming, case sensitivity, and how storing input makes your programs dynamic and reusable.

Taking input from a user

Let’s continue making our way into Python and the project. Notice that project requirements 1 and 5 are categorically different from requirement 2, which is printing something on the screen.

The project requirements that require printing the output on the screen
The project requirements that require printing the output on the screen

Now we know how to print a name on the screen using Python, but how does our code ask the elementary school student to tell us their name?

The built-in input() function

Just like print prints something on the screen, what would be the name of the built-in function that takes input from the user’s keyboard? You guessed it! Python offers us another built-in function with the name of input. ...

input()
Taking the input using the input() function
...