I've hit a wall.
I need to search for a particular value and output the whole dictionary that the value is in:
This is my Original dictionary:
dictionary1={ "Perth":{"Division": "Perth","Staff number":10,"Year formed":1995},"Darwin":{"Division": "Darwin","Staff number":5,"Year formed":2000},"Brisbane":{"Division": "Brisbane","Staff number":15,"Year formed":1995}}
After calling the function with the argument 1995,year_formed_data(1995), the output should be:
{1995:[{"Division": "Perth","Staff number":10,"Year formed":1995},{"Division": "Brisbane","Staff number":15,"Year formed":1995}]}
Likewise if:
year_formed_data(2000)
{2000:[{"Division": "Darwin","Staff number":5,"Year formed":2000}]}
This is my code:
def year_formed_data(yr):
year={}
for business,data in dictionary1.items():
if data ==yr:
year[yr]={list({"Division": ,"Staff number": ,"Year formed": }
print(year)
year_formed_data(1995)
Thanks again!