python

Get input as a number in python

You wanna know how to get input as a number in python, right? Don't we all. Well, it's really easy. You just do x = int(input('Please enter a number: ')) or x = float(input('Please enter a number: ')) if you want it as a floating-point number.

# For integer input
value = int(input("Enter a number: "))

# For float input
value = int(input("Enter a float number: "))
Was this helpful?