QUESTION DATED : 02/12/2024

(Question Code : QC24120200)

  CREATE TWO DICTIONARIES, ADD KEY AND VALUES TO IT AND CHECK FOR THE COMMON KEYS IF THE COMMON KEY IS FOUND PRINT TRUE OTHERWISE PRINT FALSE .  


      ANSWER

a = {}

b = {}

keys_and_values_a = input("Enter the keys and values for dictionary a: ").split()

for i in range(0, len(keys_and_values_a), 2):

    key = keys_and_values_a[i]

    value = keys_and_values_a[i + 1]

    a[key] = value

keys_and_values_b = input("Enter the keys and values for dictionary b: ").split()

for i in range(0, len(keys_and_values_b), 2):

    key = keys_and_values_b[i]

    value = keys_and_values_b[i + 1]

    b[key] = value

for i in a.keys():

    for j in b.keys():

        if (i == j):

            print("True")

            break

    else:

            print("False")




                                                                      -----

No comments:

Post a Comment

APPLICATIONS

Support Us Help us create more useful apps! We've already built a screen recorder(availabe in APPS...