Input From the User

Explore the built-in input() function for handling user input effectively

The input() function

In Python, the input() function is used to take input from the user.

  • The input is automatically converted to a string. If you enter a number, it will also be converted to a string.

  • The input() function can take a single optional parameter, which is the prompt string. This prompt string is displayed to the user when asking for input.

Below is an executable asking for the user’s name as an input.

Please note that our platform has restrictions where you must enter the input first and then press the 'Run' button. However, when you execute the program locally, a prompt will appear on the console asking for your name. After the prompt, you can then enter your name.

Get hands-on with 1400+ tech skills courses.