In fact the problem is not in its function but in how the list of numbers is being passed to it:
t = input("Digite sua lista: ")
print(min_max(t))
This is sending a string and not a list, so your code should contain a conversion before:
def min_max(numeros):
return [max(numeros), min(numeros)]
if __name__ == "__main__":
entrada = input("Digite sua lista: ")
lista = [int(i) for i in entrada.split(",")]
maior, menor = min_max(lista)
print(maior, menor)
Of course, this conversion of mine is not perfect since it does not consider the existence of characters, fractional numbers and other things. One way to make it a little more robust would be to use the method isnumeric()
:
lista = [int(i) for i in entrada.split(",") if i.isnumeric()]
But in this case only integers larger than zero would be accepted.
min_max = lambda t: [min(t),max(t)]
– Augusto Vasques