Implement a function that takes as input three variables, and returns the largest of the three. Do this without using the Python
There are many ways to answer this question, ranging from simple to complex. Here are a few reader-submitted answers!
This first example solution uses a series of
if statements and comparisons to find the largest of 3 elements.
Another solution is a little bit less verbose, taking 3 numbers as an input, making them into a list, sorting them, and then reading off the largest element.
This last solution uses a more compact series of
if statement comparisons to cover all cases of 3 elements.
Which one is your favorite? Why?
Happy hacking!comments powered by Disqus