Python iterate Dictionary Key Nilai
a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}
for key, value in a_dict.items():
print(key, '->', value)
Zealous Zebra
a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}
for key, value in a_dict.items():
print(key, '->', value)
dictionary = {52:"E",126:"A",134:"B",188:"C",189:"D"}
for key, value in dictionary.items():
print(key)
print(value)
d = {'x': 1, 'y': 2, 'z': 3}
for key in d:
print key, 'corresponds to', d[key]
n = int(input())
ans = {i : i*i for i in range(1,n+1)}
print(ans)
# iterating through dictionary keys fast
dictKeys = list(nameOfDict.keys())
for i in range(len(dictKeys)):
print(dictKeys[i])
# iterating through dictionary values fast
dictValues = list(nameOfDict.values())
for i in range(len(dictKeys)):
print(dictKeys[i])