Exercise: Highs and Lows

Let's separate highs from the lows and then count both.

Problem Statement

You must implement the count_low_high() function. Its parameter is a list of numbers.

If a number is greater than 50 or divisible by 3, it will count as a high. If these conditions are not met, the number is considered a low.

At the end of the function, you must return a list that contains the number of lows and highs, in that order.

In case the list is empty, you may return None.

Sample Input

num_list = [20, 9, 51, 81, 50, 42, 77]

Sample Output

[2, 5] # 2 lows and 5 highs

Coding Challenge

Take some time to figure out the smartest way to solve this problem. Python’s built-in functions are also available to you. Try using them to approach and solve this problem.

If you feel stuck, you can refer to the solution review in the next lesson.

Good luck!

Get hands-on with 1200+ tech skills courses.