👋 Getting User Input in Python
One of the most important things in programming is interacting with users!
In Python, we use the input()
function to get user input.
Example: If we want to ask for a name, we can write:
name = input("What is your name? ")
Then, we can greet the user:
print("Hello, " + name + "!")
Python Code:
name = input("What is your name? ") print("Hello, " + name + "!")
Try It Yourself!
Console Output:
Output:
Click to Reveal Solution
name = input("What is your name? ")
print("Hello, " + name + "!")