Loop over dictionary keys
Looping over the "dictionary" is just like looping over the keys, but personally I prefer when we use the somedictionary.keys()
expression.
user = {
'fname': 'Foo',
'lname': 'Bar',
}
for key in user:
print(f"{key} -> {user[key]}")
# lname -> Bar
# fname -> Foo