As @mavix mentioned in a comment to another post:
In python3,
dict.keys()
returns a'dict_keys' object
instead of alist
, which does not support indexing Blockquote
One solution to this would be converting that object into a list by iterating through it. It's not the most elegant solution and shouldn't really be used if can be avoided.
first_key = [key for key in prices.keys()][0]
# ^Converts keys into a list ^Takes the first key from the list