0
How can I turn a float into its nearest integer in Python3
when I use int() function on a float like 6.6666...., it turns to 66. What can I do to turn it into 67??
2 Answers
+ 8
There's a function called round.
round(6.666) ---> 7
round(3.333) ---> 3
round can take second argument, which tells the accuracy of the rounding.
round(1/3, 2) ---> 0.33
round(12345, -3) ---> 12000
0
M Tamim thanks, buddy!