olliesilvester / htss-rig-bluesky-work-experience

Config and scripts for using hte HTSS rigs
Apache License 2.0
0 stars 0 forks source link

Generators part 1 #5

Open olliesilvester opened 2 months ago

olliesilvester commented 2 months ago

Write a generator function count_up_to that takes a maximum value and yields numbers from 1 to this maximum. Then, write another generator function count_down_from that takes a starting value and yields numbers from starting value down to 1. Use yield from to combine both generators into a single generator function count_up_and_down.

Eg

def count_up_and_down(n):
    yield from ...
    yield from ...

generator = count_up_and_down(10)
for value in generator:
    ...