def compareKeys(dict1, dict2):
return set(dict1.keys()) == set(dict2.keys())
# przykład użycia
dict1 = { 3: "Ala", 1: "ma", 6: "kota" }
dict2 = { 1: "Monty", 6: " ", 3: "Python" }
print(compareKeys(dict1, dict2)) # True
dict2 = { 1: "Ala", 2: "ma", 3: "kota" }
print(compareKeys(dict1, dict2)) # False
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
def compareKeys(dict1, dict2):
return set(dict1.keys()) == set(dict2.keys())
# przykład użycia
dict1 = { 3: "Ala", 1: "ma", 6: "kota" }
dict2 = { 1: "Monty", 6: " ", 3: "Python" }
print(compareKeys(dict1, dict2)) # True
dict1 = { 3: "Ala", 1: "ma", 6: "kota" }
dict2 = { 1: "Ala", 2: "ma", 3: "kota" }
print(compareKeys(dict1, dict2)) # False