In Python, we can take user input directly by using input() function. This input function gives a return value as a string/character hence we have to pass that into a variable.
Syntax:
variable=input()
But the input function returns the value as a string. We can typecast them whenever required to another datatype.
Python
variable_name = int(input())
variable_name = float(input())
Example:
name = input("Enter the name: ")
print(name)
The Output Of This Code Will Be:
Python
Enter the name: Priti
Priti
Sometimes we need to change the types of variables after taking input from the user. Read more
I hope you understand how to take Input From users in Python. If you do not understand this topic just comment below with your email ID, and I will mail back to you.
Post Views: 54