I have 2 functions below. When I loop though list_of_dicts in my dict_list() I am able to print out each dictionary in this list but when I return i in dict_list() and try to print out the return in get_dicts(i) it only returns / prints {'id': '33333', 'env': 'dev', 'cost': '250.00'} aka the first iteration of my loop. How can I return each dictionary so I can can then modify that data in get_dicts(i) something like if i['env'] == 'prod' i['env'] = "production" just an example but trying to avoid creating a list if possible.
def dict_list():
list_of_dicts = [{'id': '12345', 'env': 'prod', 'cost': '50.00'}
, {'id': '67890', 'env': 'dev', 'cost': '100.00'}
, {'id': '11111', 'env': 'stage', 'cost': '150.00'}
, {'id': '22222', 'env': 'prod', 'cost': '200.00'}
, {'id': '33333', 'env': 'dev', 'cost': '250.00'}]
for i in list_of_dicts:
print(i)
return i
def get_dicts(i):
print(i)
def main():
i = dict_list()
get_dicts(i)
if __name__ == '__main__':
main()