I'm working on a practice problem that says, "Make a function that receives an integer as an argument (step) and that prints the numbers from 0 to 100 (included), but leaving step between each one. Two versions: for loop and a while loop.
I can do it using a foor loop:
def function(x):
count = 0
for x in range(0, 100, x):
print(x)
I can't seem to make it work with a while loop. I've tried this:
def function(x):
count = 0
while count <= 100:
count += x
print(count)
so please, help. Thank you!
whileversion, you should print before you increase the step. Also, you don't needcount = 0in theforversion.