int()
truncates float values, removing the non-integral portion of the number. You are looking for rounding instead.
You can use the round()
function for that:
>>> round(4.99)
5
solved Python int() to the nearest value
int()
truncates float values, removing the non-integral portion of the number. You are looking for rounding instead.
You can use the round()
function for that:
>>> round(4.99)
5
solved Python int() to the nearest value