Complete the code to initialize an empty adjacency list for a graph with 3 nodes.
graph = {i: [] for i in range([1])}The graph has 3 nodes numbered 0, 1, and 2. Using range(3) creates keys for these nodes with empty lists as values.
Complete the code to add an edge from node 0 to node 2 in the adjacency list.
graph[0].[1](2)
extend with a single integer causes an error.remove deletes elements instead of adding.Use append to add node 2 to the adjacency list of node 0.
Fix the error in the code to correctly add an edge from node 1 to node 0.
graph[1].[1](0)
add causes an AttributeError.extend with an integer causes a TypeError.append is the correct method to add a single neighbor to the adjacency list.
Fill both blanks to create an adjacency list for nodes 0 to 4 and add an edge from node 3 to node 1.
graph = {i: [] for i in range([1])}
graph[3].[2](1)range(4) misses node 4.insert adds at a specific position but is unnecessary here.Use range(5) to create nodes 0 to 4. Use append to add node 1 to node 3's adjacency list.
Fill all three blanks to create an adjacency list for nodes 0 to 3, add an edge from node 2 to node 0, and from node 0 to node 3.
graph = {i: [] for i in range([1])}
graph[2].[2](0)
graph[0].[3](3)extend with single integers causes errors.insert is unnecessary here.Use range(4) for nodes 0 to 3. Use append to add neighbors to adjacency lists.
