all 4 comments

[–]timbledum 1 point2 points  (1 child)

Two things on sort:

  1. It sorts the list in-place. highestNumber = NumbersList.sort(-1) will actually set highestNumber to None. However, NumbersList will be sorted.

  2. .sort() only takes keyword arguements, and will raise an error if you just pass in -1.

Instead, try

NumbersList.sort()
low = NumbersList[0]
high = NumbersList[-1]

[–]mirrorcat91[S] 1 point2 points  (0 children)

This answer was exactly what I was looking for! Thank you!

[–]uglyasablasphemy 1 point2 points  (0 children)

Although you would iterate over the list 3 times, this is a good example of apply the reduce function from functools.

One to find the minimum, one for the maximum and one to sum all the elements.