input() Function

Syntax: 

input(prompt)

prompt [optional]: any string value to display as input message

Ex: input(“What is your name? “)

Returns: Return a string value as input by the user.

By default input() function helps in taking user input as string.
If any user wants to take input as int or float, we just need to typecast it.

Python input() Function

Python input() function is used to take user input. By default, it returns the user input in form of a string.

Similar Reads

input() Function

Syntax:  input(prompt) prompt [optional]: any string value to display as input message Ex: input(“What is your name? “) Returns: Return a string value as input by the user....

Python input() Function Example

Python3 # Taking input as string color = input("What color is rose?: ") print(color)   # Taking input as int # Typecasting to int n = int(input("How many roses?: ")) print(n)   # Taking input as float # Typecasting to float price = float(input("Price of each rose?: ")) print(price)...

Contact Us