##Solution - Occupancy Dictionary
The solution notebook can be downloaded from:
https://anaconda.org/UCL-RITS/module13-occupancydictionarysolution/notebook
With this maze structure:
house = {
'living' : {
'exits': {
'north' : 'kitchen',
'outside' : 'garden',
'upstairs' : 'bedroom'
},
'people' : ['James'],
'capacity' : 2
},
'kitchen' : {
'exits': {
'south' : 'living'
},
'people' : [],
'capacity' : 1
},
'garden' : {
'exits': {
'inside' : 'living'
},
'people' : ['Sue'],
'capacity' : 3
},
'bedroom' : {
'exits': {
'downstairs' : 'living',
'jump' : 'garden'
},
'people' : [],
'capacity' : 1
}
}
We can get a simpler dictionary with just capacities like this:
{name : room['capacity'] for name, room in house.items()}
« {‘bedroom’: 1, ‘garden’: 3, ‘kitchen’: 1, ‘living’: 2}