Може ли помощ с кода плс. Как да спазя ограниченията? Мисля, че това ми е грешката, но може и да бъркам
Longest String
You are very hungry, but there is a problem - there is just too much options and you can only eat one thing. Being a clever programmer, you decide to form objective critera and eat the food with the longest name. Also, why count manually in 30 seconds, when you can spend 15 minutes writing a script to do the counting?
Input
- The input consists of at least 2 lines
- The last line is always END
- Each different food is on a new line
Output
- Print the food with the longest name. If two or more foods have equal length, print the last one.
Constraints
1 <= lines of input <= 50 The last line will always be END
Sample Tests
Input
pizza
macaroni
kiufte
banica
END
Output
macaroni
Input
banica
pizza
kiufte
END
Output
kiufte
food=’’
max_len_food=’’
while food!=‘END’:
food=input()
if len(food) >= len(max_len_food):
max_len_food=food
print(max_len_food)
И втори вариант, отново същата грешка
Test cases
Test case #1: Accepted [0.06 s, 9.80 MB]
Test case #2: Accepted [0.06 s, 9.80 MB]
Test case #3: Accepted [0.06 s, 9.80 MB]
Test case #4: Accepted [0.06 s, 9.80 MB]
Test case #5: Accepted [0.06 s, 9.79 MB]
Test case #6: Wrong Answer [0.06 s, 9.80 MB]
Your output (clipped)
END