Dec-07-2019, 11:01 AM
The float has the method
You can use it.
By the way, if you expect different results with rounding, it's
scientific rounding: Half to even.
is_integer()
.You can use it.
By the way, if you expect different results with rounding, it's
scientific rounding: Half to even.
lst = [2, 3.96343, 5.635, 2.32463255, 7.0, 12, 1.0] k=[] for i in lst: if isinstance(i, int): k.append(i) elif isinstance(i, float): if i.is_integer(): k.append(int(i)) else: k.append(round(i,2))
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!