Challenge: Working with Coroutines
Test your understanding of coroutines with these coding questions.
We'll cover the following...
We'll cover the following...
Problem 1
In this problem, you are required to implement a coroutine running_average()
that calculates the running average of numbers sent to it.
Requirements
- The coroutine should:
- Start with no numbers.
- Accept numbers using
.send(value)
. - After each number is sent, yield the current running average.
- If
.send()
is called withNone
, the coroutine should stop and return the final average.
...