How do you find the first key in a dictionary?

前端 未结 12 888
清酒与你
清酒与你 2020-11-27 10:58

I am trying to get my program to print out \"banana\" from the dictionary. What would be the simplest way to do this?

This is my dictionary:

         


        
12条回答
  •  眼角桃花
    2020-11-27 11:57

    Well as simple, the answer according to me will be

    first = list(prices)[0]

    converting the dictionary to list will output the keys and we will select the first key from the list.

提交回复
热议问题