I need help in debugging code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

28th Apr 2020, 11:48 PM
ya Bois here
ya Bois here - avatar
3 Answers
+ 1
Thank you so much! I really needed this.
29th Apr 2020, 3:14 PM
ya Bois here
ya Bois here - avatar
29th Apr 2020, 1:14 PM
Raj Laxmi Verma
Raj Laxmi Verma - avatar
0
Glad to help ya Bois here
29th Apr 2020, 5:36 PM
Raj Laxmi Verma
Raj Laxmi Verma - avatar