I'm new to Python and I am having a small problem I want to solve
a={"1" : 3, "2" : 3, "6":3}
I have this dic and I would like to get the maximum key out of him for example in the dictionary above I would like to get the key 6 as a value
I'm new to Python and I am having a small problem I want to solve
a={"1" : 3, "2" : 3, "6":3}
I have this dic and I would like to get the maximum key out of him for example in the dictionary above I would like to get the key 6 as a value
On
If you want the original key (as as string, not an integer), you could simply use max with int as key argument:
a = {"1" : 3, "2" : 3, "6":3}
max(a, key=int)
# '6'
There are many ways, one way of doing it is:
Or a human readable format, so you can understand the logic: