I'm looking for a more pythonic way to get the maximal length of the values for each key in a list of dictionaries.
My approach looks like this
lst =[{'a':'asdasd', 'b': 123},{'a': 'asdasdasdas'}, {'a':123,'b':'asdasd'}]
dct = {}
for l in lst:
for key in l:
dct.update({key: max(dct.get(key,0), len(str(l.get(key,0))))})
print(dct)
The output gives
{'b': 6, 'a': 11}
The str function is needed to get the length of integers (and also Nones)
Is this approach "pythonic" or is there a smoother, more readable way using list comprehensions or similar methods.