Skip to content

Python, Accepting Input

In a Python command line application you can display information to the user using the print() function:

name = "Roger"
print(name)

We can also accept input from the user, using input():

print('What is your age?')
age = input()
print('Your age is ' + age)

This approach gets input at runtime, meaning the program will stop execution and will wait until the user types something and presses the enter key.

You can also do more complex input processing and accept input at program invocation time, and we’ll see how to do that later on.

This works for command line applications. Other kinds of applications will need a different way of accepting input.


→ Here's my latest YouTube video

→ Get my Python Handbook
→ Get my Python Handbook

→ I wrote 17 books to help you become a better developer, download them all at $0 cost by joining my newsletter

JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025

Bootcamp 2025

Join the waiting list