Using a while and an if statement i need to write the function div_3_5 (start, end) that computes the number of integers from start up to, but not including end that are divisible by 3 or 5.
I do not need to list the numbers just state how many there are.
I get an error either saying i need a return statement or that when variables are given the answer is incorrect using this code.
def div_3_5(start, end):
x = 0
while start < end:
x = x + start
start = start + 1
if (x%3 == 0) or (x%5 == 0):
return x
printlines in to see how the variables change; that is not doing what you want it to. Better variable names (e.g.currentandtotal) would also help you visualise the process.returnkeyword actually does? When it runs, what does it return from, and where does it return to? Therefore, what happens when the if statement runs the first time? And the second time? Does it run a second time?