Jun-18-2020, 08:56 PM
items() returns all of the keys/values in the dictionary, one tuple at a time. So each time through the loop,
This is the form of an augmented assignment. It's basically the same thing as writing
k
is set to one of the keys, and v
to the corresponding value of that key.>>> d = {'key': 'value', 'A': 1, 'B': 2} >>> list(d.items()) [('key', 'value'), ('A', 1), ('B', 2)]The empty string is probably a typo. I'd guess someone wanted a blank space between the key and the value in the print and it became empty instead of a space.
This is the form of an augmented assignment. It's basically the same thing as writing
Item_total = Item_total + v