May-07-2021, 07:52 PM
This version is fast and short
my_list = ['apple','pear','banana','orange','shrimp','plum'] biggest = len(max(my_list, key=len)) my_list1 = [x for x in my_list if len(x) != biggest] print(my_list1)
Output:['apple', 'pear', 'plum']
biggest is the length of the longest item in my_list. I then use a list comprehension to eliminate items of that length. Banana, orage, and shrimp are all 6 letters long.