Last active
March 5, 2017 19:02
-
-
Save jonathan-kosgei/e449a38f91560983206d2d016f785c46 to your computer and use it in GitHub Desktop.
Find largest number in nested number list 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 max_in_nested_number_list(numbers): | |
largest = 0 | |
for item in numbers: | |
if isinstance(item, list): | |
numbers.append(max_in_nested_number_list(item)) | |
else: | |
largest = item if item>largest else largest | |
return largest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment