Inside the window
Inputs
values is a list of 0 to 14 whole numbers, each from 0 to 50. low and high are whole numbers from 0 to 50, and low is at most high.
Your tasks
- Create a number
countthat starts at 0. - Use a loop over
values. Add 1 tocountwhen the number is at leastlowand at mosthigh. - Complete
countBetweenso it returnscount. Return it, do not print it.
Example
With values = [5, 10, 15, 20, 25] and low = 10 and high = 20, countBetween returns 3.
Rules
- Both ends are included.
Test data
TEST DATA 1: values is [5, 10, 15, 20, 25], low is 10, high is 20
TEST DATA 2: values is [], low is 0, high is 5
Practice focus
Put an if inside the loop to keep, skip or change items. Filtering, mapping and comparing neighbours show up in nearly every array question.