Contact: aviboots(AT)netvision.net.il
36,611 questions
47,864 answers
573 users
my_dict = {'a': 1, 'b': 2, 'c': 3} for key, value in my_dict.items(): print(f"Key: {key}, Value: {value}") ''' run: Key: a, Value: 1 Key: b, Value: 2 Key: c, Value: 3 '''
my_dict = {'a': 1, 'b': 2, 'c': 3} # Iterating over keys for key in my_dict.keys(): print(f"Key: {key}") # Iterating over values for value in my_dict.values(): print(f"Value: {value}") ''' run: Key: a Key: b Key: c Value: 1 Value: 2 Value: 3 '''
my_dict = {'a': 1, 'b': 2, 'c': 3} for key in my_dict: print(f"Key: {key}, Value: {my_dict[key]}") ''' run: Key: a, Value: 1 Key: b, Value: 2 Key: c, Value: 3 '''