Search code snippets, questions, articles...

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: "))
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Was this helpful?