How do you find the first key in a dictionary?

前端 未结 12 878
清酒与你
清酒与你 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:30

    For Python 3 below eliminates overhead of list conversion:

    first = next(iter(prices.values()))
    

提交回复
热议问题