We can use a 2 dimensional list (matrix) to represent the current state of a parking lot like this:
parking_state = [
[1,0,1,1,0,1],
[2,0,1,1,0,1],
[1,0,2,1,0,1],
[1,0,1,1,0,1],
[1,0,1,1,0,2],
[1,0,1,1,0,1],
]
- Create a function
get_parking_lot()
that returns a dictionary withtotal_slots
,available_slots
andoccupied_slots
like the following:
state = {
total_slots: 12,
available_slots: 3,
occupied_slots: 9
}
-
Declare the key names to store the values.
-
You have to do a nested loop.
-
Compare the statements.