Change the Type of Input in Python

Last Updated : 23 Mar, 2026

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

Example: Taking the default (string) user input:

Python
color = input("What color is rose?: ")
print(color)

Output

What color is rose?: Red
Red

We can typecast the user input to integer type by wrapping the input statement by int():

Python
n = int(input("How many roses?: "))
print(n, type(n))

Output

How many roses?: 88
88 <class 'int'>

We can typecast the user input to float or decimal type by wrapping the input statement by int():

Python
price = float(input("Price of each rose?: "))
print(price, type(price))

Output

Price of each rose?: 69.420
69.420 <class 'float'>

Comment