0
I arrived at the following function:
def func6a(lista):
maior = 0
for el in lista:
if type(el) == list:
maior = func6a(el)
else:
if len(el) > maior:
maior = el
return maior
But unfortunately,:
*if Len(el) > larger:
Typeerror: '>' not supported between instances of 'int' and 'str'*
My question is: how can I escape this error ? I’ve been waiting for you, but I don’t know how to escape!
Obs: parameters must be strings or nested list containing strings!
max(['A', 'ABCDEFG', 'ABC', 'B'])
returns'B'
, then the first part of your answer is wrong. The functionmax
returns the largest string in alphabetical order, without taking into account their size.– Woss
Adinanp, thanks for the explanation, it turns out the idea is not to use native functions in python. The teacher does not allow, my mistake not punctuate it in the statement,!
– GratefullyDead
Anderson, you’re right. I saw that in your answer you make the right use of
max
with the argumentkey
. I edited my reply, thank you for pointing out the error.– adinanp