← Back to challenges

Difference of Max and Min Numbers in List

PythonMediumarraysnumbersmathloops

Instructions

Create a function that takes a list and returns the difference between the biggest and smallest numbers.

Examples

difference_max_min([10, 4, 1, 4, -10, -50, 32, 21]) ➞ 82
# Smallest number is -50, biggest is 32.

difference_max_min([44, 32, 86, 19]) ➞ 67
# Smallest number is 19, biggest is 86.

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Concatenating Two Integer Lists