iterate over dictionary django
# Assuming you have a Django view function with a dictionary called 'my_dict'
def my_view(request):
my_dict = {
'key1': 'value1',
'key2': 'value2',
'key3': 'value3',
}
# Iterate over the dictionary using items() method
for key, value in my_dict.items():
# Print the key and value for each iteration
print(f'Key: {key}, Value: {value}')