Menu Close

Display items in Dictionary Python…FTC

Write a program to get four dictionary items and display all the key-values format using update function and items() function

dict={}
for i in range(4):
    key=int(input())
    value=int(input())
    dict[key]=value
for key,value in dict.items():
    print("[(" + str(key) + ", " + str(value) + ")]")
INPUT
10
-10
20
-20
30
-30
40
-40

OUTPUT
[(10, -10)]
[(20, -20)]
[(30, -30)]
[(40, -40)]

ILLUSTRATION

Executed using python3