Quick code challenge: find the largest and smallest number in a list, python

·

0 min read

This is another of the quick code challenges from Florin Pop on twitter, finding the largest number in a list. So this is my solution which finds the largest and smallest number. The portion of code that does the searching is similar, just flip < to >

The solution also uses python's random library to generate ten random numbers between 1 and 100 and saves them in a list. The two functions then use a for loop and a conditional statement to go through the list to find the largest and smallest number.

largest and smallest.png

You can checkout the code on this gist gist.github.com/DevShasa/d42a0e3f884a7fad65..

There is probably a more elegant way to do it that would make the code shorter, and eliminate one function, suggestions and improvements are welcome.