How to filter dictionary keys based on its corresponding values

前端 未结 6 1090
南笙
南笙 2021-01-30 04:50

I have:

dictionary = {\"foo\":12, \"bar\":2, \"jim\":4, \"bob\": 17}

I want to iterate over this dictionary, but over the values instead of the

6条回答
  •  再見小時候
    2021-01-30 05:45

    How about this:

    dictionary = {"foo":12, "bar":2, "jim":4, "bob": 17}
    for val in dictionary.values():
        # do something
    

提交回复
热议问题