Practice: find_range
Contents
Practice: find_range#
Write a function named find_range
that accepts a list
of int
s as a parameter and returns the range of values contained in the list. The range is defined to be one more than the difference between its largest and smallest elements.
For example, consider the list [12, 17, 6]
. The largest element in this list is 17
and the smallest is 6
, so the range is 12
(one more than 17 - 6
). If the largest and smallest values are the same, the range is 1
.
Requirements#
You may assume that the list contains at least one element (that its length is at least 1).
You should not modify the contents of the list.
You should not use a “nested-loop” to solve this problem (a loop inside a loop).
Note
This problem was created on Code Step by Step .