xxxxxxxxxx
"""
NOTE: dictionaries do NOT remember the order in which
key : value pairs have been stored
"""
d = {"a" : 5, "b" : 1, "c" : 8, "d" : 4, "e" : 3, "f" : 10, "g": 2}
# getting the first n key : value pairs
n = 3
first_n = dict(zip(list(d.keys())[:n], list(d.values())[:n]))
first_n
>>> {'a': 5, 'b': 1, 'c': 8}
xxxxxxxxxx
my_dict = {'foo': 'bar', 'spam': 'eggs'}
next(iter(my_dict)) # outputs 'foo'
xxxxxxxxxx
my_dict = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
# Get the first element of the dictionary
first_element = next(iter(my_dict.values()))
print(first_element)