Created
November 2, 2019 10:56
-
-
Save MM-coder/ce71a66566f16f2aa5e90f712519e49a to your computer and use it in GitHub Desktop.
Get the max of a list without using the inbuilt max() function
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
a = [5,9,19,0,3,-45,7,3,-20] | |
b = [-19,2,3,-8,3.5,18.9, 24] | |
def maximo(lista: list): | |
maximo = lista[0] | |
for i in lista: | |
if maximo < i: | |
maximo = i | |
return maximo | |
print("O maximo da lista a e: " + str(maximo(a))) | |
print("O maximo da lista b e: " + str(maximo(b))) | |
if maximo(a) > maximo(b): | |
print("O maximo da lista a e maior do que o da lista b") | |
elif maximo(a) < maximo(b): | |
print("O maximo da lista b e maior do que o da lista a") | |
else: | |
print("Os maximos das listas a e b sao iguais") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment