Last active
May 22, 2018 18:49
-
-
Save nara-l/770b1e12efbb207b2d62001361d3ffe5 to your computer and use it in GitHub Desktop.
Finding the largest number in a list without usiing for loop python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_largest_num(Li): | |
if len(Li) ==1: | |
return Li[0] | |
x1 = Li[0] | |
x2 = find_largest_num(Li[1:]) | |
if x1 > x2: | |
return x1 | |
else: | |
return x2 | |
'''Usage''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment