Python Iterate Słownik Wartość kluczowa
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)
a_dict = {'apple':'red', 'grass':'green', 'sky':'blue'}
for key in a_dict:
print key # for the keys
print a_dict[key] # for the values
a_dict = {"color": "blue", "fruit": "apple", "pet": "dog"}
# Will loop through the dict's elements (key, value) WITHOUT ORDER
for key, value in a_dict.items():
print(key, '->', value)
new_list = [something(key, value) for key, value in a_dict.items()]
foreach (var (key, value) in someDictionary) // loop through key and value; WARNING: NON-MUTABLE