Answers for "how to get the longest string in a list python"

3

how to find the longest string in a list in python

a_list = ["a_string", "the_longest_string", "string"]
longest_string = max(a_list, key=len)
print(longest_string)
Posted by: Guest on April-17-2021
0

python longest word in string

def find_longest_word(word_list):  
    longest_word =  max(word_list, key=len)
    return longest_word
Posted by: Guest on November-02-2020
0

python longest list in list

def longest(list1):
    longest_list = max(len(elem) for elem in list1)
    return longest_list
Posted by: Guest on June-26-2020
0

how to find the longest string python

max(a_list, key=len)
Posted by: Guest on November-22-2020

Code answers related to "how to get the longest string in a list python"

Python Answers by Framework

Browse Popular Code Answers by Language