This is a great use for a (list) comprehension:
names = ["David", "Olivia", "Charlotte"]
lengths = (len(name) for name in names)
print(max(lengths))
Above just uses a generator comprehension, but if you used brackets instead of parens you'd create a list:
lengths = [len(name) for name in names]
The generator is somewhat faster because you only move over the list once. max() lets you shorthand the generator:
print(max(len(name) for name in names))
max() also lets you do this:
max(names, key=len)
In this case, the key parameter is taking a function that returns a value that can be used to determine the maximum value. This returns the value of the longest item:
>>> names = ["David", "Olivia", "Charlotte"]
>>> max(names, key=len)
'Charlotte'
Alternatively, if you want to use reduce (a functional style approach), you can do this:
>>> from functools import reduce
>>> reduce( lambda x, y: max(x, len(y)), names, 0)
9
This moves through the list and compares a starting value (0) with the length of each new value (len(y)), and chooses one at each step. This is basically equivalent, but can be a useful alternative in more nuanced circumstances.