xxxxxxxxxx
CCommand: input()
What is input: Input Function
Description: The input() function is used to take input from the user as a string.
Example: user_input = input("Enter your name: ") will prompt the user to enter their name.
xxxxxxxxxx
name = input("Hi! What’s your name ? ")
print("Nice to meet you " + name + "!")
age = input("How old are you ? ")
print("So, you are already " + str(age) + " years old, " + name + " !")
xxxxxxxxxx
# Take user input in python
age = int(input("Type the age: "))
if age <= 18:
print("You are too young to enter here")
xxxxxxxxxx
string = input("Enter a string: ")
number = int(input("Enter a number: "))
xxxxxxxxxx
Use the input() method
Example
#code
name = input("Name Please: ")
print(f'Hello {name}, what can I do for you?')
#console
Name Please:
>>> Steve
Hello Steve, what can I do for you?