I have to write a program that shows a column of kilograms and a column of pounds, starting at 1 kilogram and ending 99, increasing every step with 2.
I have the following code, and the range() works for the pounds part, but not for the kilograms part. It stays always 1 for the kilograms.
for k in range(1,3,1):
for i in range(1,101,2):
for j in range(2,223,3):
Because you use
break with in a loop.
In python you don't end a loop with anything but a decreased indentation. Remove your
break statements and try again.
break statements ends the current loop unconditionally. For example,
s = 0 for i in range(1, 101): s = s + i
s equal to 5050. However, if you break it some where, like
s = 0 for i in range(1, 101): s = s + i if i == 5: break
s will stop increasing on 15.
As commentors say, you should learn the basics of python from some tutorial. There are pretty many free tutorials on the internet. Don't haste.
Besides, if you wanna use float steps in ranges, take a look at this answer; or rather, see comments below for a simple answer.