Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # up_down.py
- def up_down(lowest_value, highest_value, step=1, current='void'):
- if current == 'void':
- current = lowest_value
- while True: # Begin infinite loop
- yield current
- current += step
- if current <= lowest_value or current >= highest_value:
- step *= -1 # Turn around when either limit is hit
- test = up_down(-5, 10)
- count = 0
- for j in test:
- print(j) # for demonstration purposes
- count += 1
- if count >= 50: # your ending condition here
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement