Asking For User Input In Python

In this page, I quickly go over asking for user input in Python. (Note that error handling is not mentioned here.)

Reference: Starting Out With Python – Second Edition By Tony Gaddis


The input() Function

There are times when you need information from the user in order to run a program or do tasks in Python. Python’s input() function asks the user for a value or text. This input can be stored in a variable and the contents can be displayed with a print() statement.


An Example

Here is a short example of asking for user input. I ask for a first name and an age. The int() function is used to convert the numeric age answer into a whole number.






Leave a Reply