Write a function called listrange()
that will return the range of a list of numbers.
The function will receive a Python list
passed in as a parameter. The range of a list is the difference between the maximum value and the minimum value of the list.
You may assume that the list will always have at least two values.
Examples:
listrange( [1, 2, 3, 4, 5] )
returns 4
(because 5 - 1 is 4)listrange( [87, 34, 58, 9, 34, 97, 23] )
returns 88
(because 97 - 9 is 88)listrange( [1337, 1337] )
returns 0
For +20 bonus points, make your function work no matter what kind of numbers are in the list. Even if the numbers are in the billions or are all negative, your code should still be able to find the largest and smallest values correctly.
©2017 Graham Mitchell