Feb-14-2023, 02:02 PM
(Feb-13-2023, 11:13 PM)bowlofred Wrote: Simple division always creates a float. You can check if the float is an integer and convert back if you would like.That's a nice way to do it!
quotient = 10 / 5 if quotient.is_integer(): quotient = int(quotient) print(quotient)
I'm still wondering though, why 4/2 couldn't just give an integer? Why a de facto float result was considered the best choice? After all, multiplication gives inetegers when it can... Why not division too?