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
# Taking string input
a = input("Enter a string: ")
print("String is: ", a)
# Taking integer input
b = int(input("Enter an integer: "))
print("Integer is: ", b)
# Taking float input
c = float(input("Enter a float value: "))
print("Float value is: ", c)
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?