There are two lists
l1 = ['k1','k2','k3','k3','k4', 'k5']
l2 = ["1.2.3","abc-2.3.4","xyz-def-5.6.8", "xyz-def-5.6.7","ghjb-5.6.7","7.8.9"]
I need to get these items as key:value pair in a dictionary, along with highest value of duplicate elements. Since dictionary holds the unique keys, one of the duplicate elements will be overridden.
print(dict(zip(l1, l2)))
{'k1': '1.2.3', 'k2': 'abc-2.3.4', 'k3': 'xyz-def-5.6.7', 'k4': 'ghjb-5.6.7', 'k5': '7.8.9'}
but from above output, i need highest value xyz-def-5.6.8 instead of xyz-def-5.6.7
Tried, print(list(zip(l1, l2))), output as below
[('k1', '1.2.3'), ('k2', 'abc-2.3.4'), ('k3', 'xyz-def-5.6.8'), ('k3', 'xyz-def-5.6.7'), ('k4', 'ghjb-5.6.7'), ('k5', '7.8.9')]
How do I achieve it ?
Is it possible to format this list of tuples or any other way to get desired ?
l1 = ['k1','k2','k3','k3','k4', 'k5', 'k6', 'k7', 'k6']
l2 = ["1.2.3","abc-2.3.4","xyz-def-5.6.8", "xyz-def-5.6.7","ghjb-5.6.7","7.8.9", "1:2.3.4-3ubuntu0.1", "1.2.3-1.2build3", "1:2.3.4-3ubuntu0.2"]
These can't be same format across all the keys but it can be same across the certain duplicate keys, Say k6 has one format, k3 has another format.