Write a program to Test for Even values dictionary values lists and print it


Topic: Write a program to Test for Even values dictionary values lists and print it

Solution

test_dict = {"Gfg" : [6, 7, 3],  
             "is" :  [8, 10, 12, 16],  
             "Best" : [10, 16, 14, 6]} 
  
  
res = dict() 
for sub in test_dict: 
    flag = 1
      
    # checking for even elements 
    for ele in test_dict[sub]: 
        if ele % 2 != 0: 
            flag = 0
            break
    # adding True if all Even elements 
    res[sub] = True if flag else False
  
print("The computed dictionary : " + str(res))



List all Python Programs