VOOZH about

URL: https://www.geeksforgeeks.org/python/change-the-type-of-input-in-python/

⇱ Change the Type of Input in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

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:

Output

What color is rose?: Red
Red

Taking Integer Inputs

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

Output

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

Taking Float or Decimal Inputs

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

Output

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

Comment
Article Tags: