Google Colab find max value in a dictionary - TypeError: 'str' object is not callable

789 views Asked by At

It may sound strange but when I try to run the following code in Google Colab to find the maximum value of a dictionary:

a_dictionary = {"a": 1, "b": 2, "c": 3}

max_key = max(a_dictionary, key=a_dictionary.get)

print(max_key)

I get the following error: "TypeError: 'str' object is not callable"

But that code works perfectly fine on my local Spyder. Any advice appreciated.

0

There are 0 answers