I wrote a script that loops through the dictionary and prints keys and values separately. The code is as follows:
dict = {"key1":"value1","key2":"value2"}
list1 = list(dict.keys())
list2 = list(dict.values())
i = 0
while i < len(list1)
print(list1[0])
When I execute the script, key1
prints multiple times, while I expect key1
, key2
to be printed.