0
Convert input to int in python
int(input()) ? Gives me an error?
6 Answers
+ 2
If you want an input string to be an int even when the input is a float just wrap the float() with an int(). The int() can convert a float to int, but not a string with float text "3.2".
int(3.2) # ok
int("3.2") # error
int(float("3.2")) # ok
+ 1
What error ?
How you tried..Can you Share the saved code..
+ 1
i found the problem, thanks for the help though,... its just this on practice 26.2 thats causing an error
0
maybe you give float or invalid int...
you could try float(input()) ;)
0
float(input()) works perfectly
0
int: parse to integer
float: parse to decimal