0
I need help in debugging code
So long story short, This is for a homework assignment my teacher gave me, and I'm testing it here. So I need to make a counter where t = 0.0 and the max lim is 2.0 and its adding by increments of 0.1. I wrote the code, but it counts like 0.0, 0.1, 0.2, 0.30000000000004 then so on. But it gets to 0.8 then 0.999999... Can anybody help me? Here's the code t = float(0.0) max_lim = float(2.0) while t <= max_lim: print("t =", t) t += 0.1
3 Antworten
+ 1
Thank you so much! I really needed this.
0
Use round(t,1)
Take a look
https://code.sololearn.com/c19rvlRCFAr5/?ref=app
0
Glad to help ya Bois here