Python User Input

In Python you can prompt the user to enter information using the input() function.

The following example demonstrates how to ask for a user’s name and age:

User Inputs
name = input("Enter your name: ")
age = int(input("Enter your age: ")) # Converts input to integer
print("Your name is", name, "and you are", age, "years old.")    
Enter your name: Diana Bishop
Enter your age: 28
Your name is Diana Bishop and you are 28 years old.

Previous     Next

Use the Search Bar to find content on MarketingMind.