I need to write a code where a function takes in a list and then returns the longest string from that list.
So far I have:
def longestword(alist):
a = 0
answer = ''
for i in alist:
x = i
if x > a:
a = x
answer = x
elif i == a:
if i not in alist:
answer = answer + ' ' + i
return answer
The example I have is longestword([11.22,"hello",20000,"Thanksgiving!",True])
which is supposed to return 'Thanksgiving!'
but my function always returns True
.