Sign up for free!

Sign up for free and get instant access to this course!.

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:

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:

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.

Sign up to access the rest of this lesson

You must either log in or sign up to access this lesson.

Saving Progress...

0 0 votes
Lesson Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments