Climbing steps
Inputs
values is a list of 0 to 14 whole numbers, each from 0 to 30.
Your tasks
- Create a number
countthat starts at 0. - Use a loop starting at position 1. Compare each number with the one just before it. Add 1 to
countwhen it is larger. - Complete
risingStepsso it returnscount. Return it, do not print it.
Example
With values = [3, 5, 4, 8, 8, 9], risingSteps returns 3.
Rules
- A list with fewer than 2 numbers has no steps.
Test data
TEST DATA 1: values is [3, 5, 4, 8, 8, 9]
TEST DATA 2: values is [7]
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.