Skip to content

Tag Archives: Python dictionary-programs

Given a tuple list, assign each element, its pair elements from other similar pairs. Input : test_list = [(5, 3), (7, 5), (8, 4)] Output… Read More
Given a Matrix, Convert to Dictionary with elements in 1st row being keys, and subsequent rows acting as values list. Input : test_list = [[4,… Read More
Given dictionary with value lists, extract all those items with values summing over K. Input : {“Gfg” : [6, 3, 4], “is” : [8, 10,… Read More
Given a Matrix with two columns, group 2nd column elements on basis of 1st column. Input : test_list = [[5, 8], [2, 0], [5, 4],… Read More
Given a dictionary, convert its values to absolute. Input : test_dict = {“Gfg” : -5, “is” : -7, “Best” : -2} Output : {“Gfg” : 5,… Read More
Given a list of dictionaries, with each dictionary having different keys, extract value of key K. Input : test_list = [{“Gfg” : 3, “b” :… Read More
Given a Matrix and list of keys, map each column’s values with a custom list key. Input : test_list1 = [[4, 6], [8, 6]], test_list2… Read More
Given a list of elements, perform grouping of similar elements, as different key-value lists in a dictionary. Input : test_list = [4, 6, 6, 4,… Read More
Python, Given a dictionary, perform sort, basis on keys or values. [ applicable Python >=3.6v ]. Input : test_dict = {“Gfg” : 5, “is” :… Read More
Given a dictionary, remove all keys with value equals K. Input : test_dict = {‘Gfg’ : 8, ‘is’ : 7, ‘best’ : 8, ‘for’ :… Read More
Given two lists, one of key and other values, convert it to dictionary with list values, if keys map to different values on basis of… Read More
Given list values and keys list, convert these values to key value pairs in form of list of dictionaries. Input : test_list = [“Gfg”, 3,… Read More
Given a dictionary with nested dictionaries as values, extract all the values with of particular key. Input : test_dict = {‘Gfg’ : {“a” : 7,… Read More
Given a List of single-item dictionaries, group them into dictionary value lists according to similar values.  Input : [{“Gfg” : 3}, {“is”: 8}, {“Gfg”: 18},… Read More
Given a range of values, extract all the items whose keys lie in a range of values. Input : {‘Gfg’ : 6, ‘is’ : 7,… Read More