Solution Review: Coroutine to Compute Running Maximum

The solution to the 'Coroutine to Compute Running Maximum' challenge.

We'll cover the following
Press + to interact
import math
def maximum():
result = - math.inf
while True:
value = yield result # Recieving values
if value > result: # Deciding on maximum
result = value
coroutine = maximum()
next(coroutine)
# Sending values
print(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 1200+ tech skills courses.