Complete the code to add a state transition from 'start' to 'processing'.
state_graph = {}
state_graph['start'] = [1]The transitions for a state are stored as a list of next states. So we use a list with 'processing' inside.
Complete the code to check if 'end' is a valid next state from 'processing'.
if [1] in state_graph['processing']: print('Can move to end')
We check if the string 'end' is in the list of next states from 'processing'.
Fix the error in the code to correctly add a transition from 'processing' to 'end'.
state_graph['processing'] = [1]
Transitions must be lists of states, so we use ['end'] to add the transition.
Fill both blanks to create a state graph with transitions from 'start' to 'processing' and from 'processing' to 'end'.
state_graph = {
'start': [1],
'processing': [2]
}The 'start' state transitions to ['processing'], and 'processing' transitions to ['end'], both as lists.
Fill all three blanks to define a function that returns the next states from a given state in the graph.
def get_next_states(state_graph, state): return state_graph.get([1], [2]) next_states = get_next_states(state_graph, [3])
The function looks up the given state in the graph, returning an empty list if not found. We call it with 'start' to get its next states.