- items
Loop using items
examples/dictionary/loop_items_kv.py
people = { "Tal" : "123", "Maya" : "456", "Ruth" : "789", } for name, uid in people.items(): print(f"{name} => {uid}")
Tal => 123 Maya => 456 Ruth => 789
examples/dictionary/loop_items.py
user = { 'fname': 'Foo', 'lname': 'Bar', } for tpl in user.items(): # iterates on tuples print(f"{tpl[0]} -> {tpl[1]}") print("{} -> {}".format(*tpl)) # fname -> Foo # fname -> Foo # lname -> Bar # lname -> Bar