Problem scenario
You see a dictionary used with the enumerate reserved word in Python.
Here is an example:
…
good_dict = {}
good_dict[”size”] = “medium”
good_dict[”quantity”] = “80”
good_dict[”location”] = “New_York”
good_dict[”phone”] = “555-555-5555”
for idx1, good_key in enumerate(good_dict):
…
Solution
A counter (a unique integer) can be assigned to each key. For logic-building purposes, it is beneficial. The above snippet would prepare a for loop for logic with 1) integers uniquely being assigned to the keys of the dictionary and 2) the keys of the dictionary.
…
Continue reading “Why Would You Use the enumerate Keyword with a dictionary in Python?”