Input and Output
Introduction to handling user input and outputting to the console in Python.
You've already seen outputting to the console using the print() function, e.g.:
print("Hello World!")But, how do you handle user input? This is actually quite simple: using the input() function!
userInput = input("Enter something > ")
print("You entered: {}").format(userInput)This program asks a user to enter some text, and then outputs what the user entered as a sentence using string formatting.
The string "Enter something > " passed as an argument to the input() function acts as a prompt in the console.
Last updated
Was this helpful?