+ 2
What should I do to convert input float to integer in python??
6 Respostas
+ 3
If x is your float you could use int(x) or round(x)... They don't exactly give the same results though. int(x) keeps the integer part and get rid of the decimal part while round(x) rounds it up to the nearest integer
Take a look at this for examples
https://code.sololearn.com/cxTO8C65udMh/?ref=app
+ 3
Take a look at my code again. Added some more examples to address your problem
+ 3
For more detailed information about all sorts of type conversions in Python, check out this link :)
https://www.digitalocean.com/community/tutorials/how-to-convert-data-types-in-python-3
+ 2
:) You are very welcome!
+ 1
I got it!
Thanks to you buddy:)
0
thank you:) @Yemibk
I'm having a slight trouble in my code which I've posted
if you would take a look when a float input is given it returns a ValueError