Method 4: Python Max Length of String in Set To find the maximum length of a string in a given set, use the max(my_set, key=len) function to obtain the string with the maximum length and then pass this max string into the len() function to obtain the number of characters of the max string.