Solution Review: Highs and Lows
Review the solution for the "Highs and Lows" exercise.
We'll cover the following...
We'll cover the following...
We’ll discuss two solutions to this problem.
Solution 1: Using filter and lambda
Let’s explore the first solution to the problem of highs and lows:
Explanation
Here’s a line-by-line explanation of the code for the problem highs and lows:
Line 1: Defines a function named
count_low_highthat takes one argumentnum_list, which is expected to be a list of numbers.Line 2: Checks if the length of
num_listis zero, meaning the list is empty.Line 3: If the list is empty, the function returns
None.Line 4: Creates a list named
high_listby ...