How To Create A Python Input Program

Photo by Christin Hume on Unsplash

How to create a python program that gets string input from the user

This is a Python 3 tutorial for creating an Input Program, and in order to get started I always start with a comment about what the program I am building is. By using the # key you are able to then create comments in Python.

# program that gets input from the user.
# get the user's input and greet the user with the input they selected

After the comment, I would usually import the functions I would utilize within the program. In this program, I did not use a function, so I did not have to import anything for this program.\

Next, I will greet the user with a print statement telling the user what the program does and after that, I will get input from the user to input their name as well as their nickname to provide them with a simple acknowledgment. 

print("Hello There! This program will greet you")
name = input("Enter your name: ")
nickname = input("Please enter your nickname: ")

After I have gotten the input from the user in this program, I just provide the user with a simple print statement to acknowledge them.

print("Hello " + name + " its nice to meet you! and great nickname")
print(nickname + " Wow! that's awesome!")

No comments:

Post a Comment

Flag Quiz Game

Enjoy this free android app in the google play store. If you want to learn about the many country fl...