Hello,
I encountered this issue and tried to figured out why this happened that way but was not able to. Can anyone help me with this? The one that I got compared to the presented result below was messed up in term of order. Any help is greatly appreciated.
# [ ] The
# Use the
# Use IDs (as keys) and names (as values).
# Ignore the email addresses for now.
# The created dictionary should look like:
# {57394: 'Suresh Datta', 48539: 'Colette Browning', 58302: 'Skye Homsi', 48502: 'Hiroto Yamaguchi', 48291: 'Tobias Ledford', 48293: 'Jin Xu', 23945: 'Joana Dias', 85823: 'Alton Derosa'}
My code:
I encountered this issue and tried to figured out why this happened that way but was not able to. Can anyone help me with this? The one that I got compared to the presented result below was messed up in term of order. Any help is greatly appreciated.
# [ ] The
data
list contains information about a company's employees.# Use the
data
list and an appropriate loop to create a dictionary of employees.# Use IDs (as keys) and names (as values).
# Ignore the email addresses for now.
# The created dictionary should look like:
# {57394: 'Suresh Datta', 48539: 'Colette Browning', 58302: 'Skye Homsi', 48502: 'Hiroto Yamaguchi', 48291: 'Tobias Ledford', 48293: 'Jin Xu', 23945: 'Joana Dias', 85823: 'Alton Derosa'}
My code:
data = [["Suresh Datta", 57394, "[email protected]"], ["Colette Browning", 48539, "[email protected]"], ["Skye Homsi", 58302, "[email protected]"], ["Hiroto Yamaguchi", 48502, "[email protected]"], ["Tobias Ledford", 48291, "[email protected]", "Tamara Babic", 58201, "[email protected]"], ["Jin Xu", 48293, "[email protected]"], ["Joana Dias", 23945, "[email protected]"], ["Alton Derosa", 85823, "[email protected]"]] dictionary = {} for item in data: dictionary[item[1]] = item[0] print(dictionary)