I’m just starting with programming. I have a list of a few strings and now I need to print the biggest (in length) one.
So I first want to just print the lengths of elements. I was trying things like this:
l = ("xxxxxxxxx", "yyyy","zz")
for i in range(len(l)):
So how do I do it?
First of all you don’t have a list, you have a tuple. this code will work for any sequence, however; both lists and tuples are sequences (as well as strings, sets, etc). So, the
maxfunction takes akeyargument, that is used to sort the elements of an iterable. So, from all elements oflwill be selected the one having the maximum length.