Loop using items
- items
people = {
"Tal" : "123",
"Maya" : "456",
"Ruth" : "789",
}
for name, uid in people.items():
print(f"{name} => {uid}")
Tal => 123
Maya => 456
Ruth => 789
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