w5 2
This commit is contained in:
22
week5/Dict Exercise/ex3.py
Normal file
22
week5/Dict Exercise/ex3.py
Normal file
@@ -0,0 +1,22 @@
|
||||
def main():
|
||||
print('==Exercise 3==')
|
||||
x = {'key1': 1, 'key2': 3, 'key3': 2}
|
||||
y = {'key1': 1, 'key2': 2}
|
||||
|
||||
d = {}
|
||||
|
||||
print(f"x: {x} \n y: {y}")
|
||||
|
||||
for i in x.keys():
|
||||
if i in y.keys():
|
||||
if x[i]==y[i]:
|
||||
d[i]=x[i]
|
||||
|
||||
for ii in d.keys():
|
||||
print(f"{ii}:{d[ii]}",end=" ")
|
||||
print("is present in both x and y")
|
||||
print('==End Of Ex3==')
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user