Skip to main content

Command Palette

Search for a command to run...

Day 7 - Taking User Input in python

Published
•1 min read•View as Markdown
V

I'm a Frontend Developer, passionate about learning about new Web Technologies.

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 input function returns the value as string. Hence we have to typecast them whenever required to another datatype.

Example:

variable=int(input())
variable=float(input())

We can also display a text using input function. This will make input() function take user input and display a message as well

Example:

a=input("Enter the name: ")
print(a)

Output:

Enter the name: Vivek
Vivek

More from this blog

Vivek's blog

34 posts