Reputation: 37
I want to return the counter of the while loops, i and b after every loop repetition to use in another function. I haven't found anything related to returning these values.
def dis(reps, towards, back):
t = 0 # move towards t times
b = 0 # move back b times
i = 0 # repetitions
n = 1 # counts every step
while i < reps:
while t < towards:
do_something()
i += 1
n +=1
while b < back:
do_something()
n += 1
b += 1
t = 0
b = 0
i += 1
I thought of adding another variable like counter_towards and counter_back and add a value each time but that would not fix my problem since I still would have to return these values every rep. Adding the related functions to a class might work aswlel but that would be lot of work and i thought there might be an easy answer to this question.
Upvotes: 0
Views: 78