0
Why does this give an unexpected answer?
def countdown(): i=10 while i > 0: yield i i -= 0.2 for i in countdown(): print(i) #this should count down by 0.2 The result is long decimals why?
3 odpowiedzi
+ 4
So this is not about the inaccuracy of floats?
Because they have long decimals sometimes. Try print(0.2) for an instance.
+ 1
No, I dont' think so. But thanks for answering Michael Williams
0
Would using round be useful?