structures that access by key python list code example
Example 1: dictionary in python does not support append operation
dict_append = {"1" : "Python", "2" : "Java"}
dict_append.update({"3":"C++"}) # append doesn't supported in dict
# instead , use update in dict
print(dict_append)
# output : {'1': 'Python', '2': 'Java', '3': 'C++'}
Example 2: python list comprehension
#example: removing common elements found in `a` from `b`.
a = [1,2,3,4,5]
b = [5,6,7,8,9]
# desired output: [1,2,3,4]
# gets each item found in `a` AND not in `b`
print([i for i in a if i not in b])