Level 1
0 / 100 XP

User Input

User input is essential when you are creating interactive programs. In this lesson I will be showing you how to get user input so you can build better software. Let’s start with the basic name example:

Python
fname = input("Please enter your first name") print("Hi " + fname + ", it's nice to meet you")

We can combine input with conditional logic to make sure the user provides us with what we want:

Python
number = input("Please enter a whole number greater than 5") if int(number) > 5: print("You entered a number greater than five!") else: print("Err... " + number + " is NOT greater than 5...")

It’s hard to get into interactive menus WITHOUT going into loops but that goes beyond the scope of this lesson. For now, write a few scripts to gather user input and then do something with that input.