Solution Review: Coroutine to Compute Running Maximum
The solution to the 'Coroutine to Compute Running Maximum' challenge.
We'll cover the following
import mathdef maximum():result = - math.infwhile True:value = yield result # Recieving valuesif value > result: # Deciding on maximumresult = valuecoroutine = maximum()next(coroutine)# Sending valuesprint(coroutine.send(1))print(coroutine.send(7))print(coroutine.send(3))print(coroutine.send(10))print(coroutine.send(5))print(coroutine.send(8))print(coroutine.send(12))coroutine.close() # Closing coroutine
Get hands-on with 1400+ tech skills courses.