- 1
Why this int function doesnt accept float??
In the code a,b = map(int, input().split(',')) If I put 3.5,4.5 for a,b it doesnt work Only for int...but the int function makes float to int isnt it..? Help me guys
4 Respuestas
+ 4
Nope ... Python can't convert a floatString to int.
print(int(float("3.5")))
+ 4
how about instead of mapping int() you map float()?
https://code.sololearn.com/c5Y2xgp19mXs/?ref=app
+ 2
a, b = (int(float(s)) for s in input().split(','))
+ 1
# or (but much more verbose and slightly less efficient):
a, b = map(lambda s: int(float(s)), input().split(','))