Created
May 29, 2021 05:11
-
-
Save bharathmuddada/bdccfcd5d70670e7e15cd69aafd75d40 to your computer and use it in GitHub Desktop.
Largest Element in list optimized
This file contains hidden or 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
l=[10,5,28,6,35] | |
def getmax(l): | |
if not l: | |
return None | |
else: | |
res =l[0] | |
for i in range(1,len(l)): | |
if l[i] > res: | |
res =l[i] | |
return res | |
print(getmax(l)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment