Question: Please help with the error for python HW I am trying to make vertexes with the edges as the number in the array but I

Please help with the error for python HW

I am trying to make vertexes with the edges as the number in the array but I am receiving this error Please help with the error for python HW I am trying to

#code is here in python: error is commented out to help the reader

def DFS(array):

visited = set()

order=[[0] * i for i in range(len(array))-1]

for vertex in array:

if vertex not in visited:

order.append(1,array[vertex])

visited.add(vertex)

dfs(array[vertex], visited)

def dfs(v, vis):

count =count +1

for vtx in vis :

if vtx ==0:

dfs(vtx,vis)

return count

if __name__ == '__main__':

graph = { #error is here

'2' : [2,1],

'3' : [3, 1] [3,2],

'4' : [4, 1] [4, 2] [4,3],

'5' : [5,1],

'6' : [6,1],

'7': [7 ,1] [7 ,5] [7, 6],

'8': [8 ,1] [8 ,2] [8, 3] [8 ,4],

'9':[9 ,1] [9 ,3],

'10': [10, 3],

'11':[11 ,1] [11 ,5] [11, 6],

'12':[12, 1],

'13': [13, 1] [13, 4],

'14': [14, 1] [14, 2] [14 ,3] [14, 4],

'17': [17 ,6] [17, 7],

'18': [18 ,1] [18 ,2],

'20': [20 ,1] [20 ,2],

'22': [22 ,1] [22, 2],

'26': [26 ,24] [26 ,25],

'28': [28, 3] [28 ,24] [28, 25],

'29': [29, 3],

'30': [30 ,24] [30 ,27],

'31': [31 ,2] [31 ,9],

'32': [32 ,1] [32 ,25] [32 ,26] [32 ,29],

'33': [33, 3] [33 ,9] [33, 15] [33 ,16] [33, 19] [33 ,21] [33 ,23] [33, 24] [33 ,30] [33, 31] [33, 32],

'34': [34 ,9] [34, 10] [34, 14] [34, 15] [34, 16] [34 ,19] [34 ,20] [34, 21] [34, 23] [34 ,24] [34 ,27] [34, 28] [34, 29] [34, 30] [34, 31] [34, 32] [34, 33]

}

C:\Users\Admin\py\hey.py:9: SyntaxWarning: list indices must be integers or slices not tuple; perhaps you missed a comma? '8': [8,1] [8 ,2] [8, 3] [8,4], C:\Users\Admin\py\hey-py:10: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '9':[9 ,1] [9,3), C:\Users\Admin\py\hey.py:12: Syntaxwarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '11':[11 ,1] [11 ,5] [11, 6], C:\Users\Admin\py\hey.py:14: Syntaxwarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '13': [13, 1] [13, 4], C:\Users\Admin\py\hey.py:15: Syntaxwarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '14': [14, 1] [14, 2] [14 ,3] [14, 4], C:\Users\Admin\py\hey.py:16: Syntaxwarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '17': [17,6] [17, 7], C:\Users\Admin\py\hey-py:17: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '18': [18 ,1] [18 ,2], C:\Users\Admin\py\hey.py:18: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '20': [20 ,1] [20 ,2], C:\Users\Admin\py\hey.py:19: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed comma? '22': [22 ,1] [22, 2], C:\Users\Admin\py\hey.py:20: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? "26": [26 ,24] [26 ,25), C:\Users\Admin\py\hey.py:21: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? 28': [28, 3] [28 ,24] [28, 25), C:\Users\Admin\py\hey.py:23: Syntaxwarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '30': [30 ,24] [30 ,27], C:\Users\Admin\py\hey-py:24: Syntaxwarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '31': [31 ,2] [31 ,9], C:\Users\Admin\py\hey.py:25: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '32': (32 ,1] [32 ,25] [32,26] [32,29], C:\Users\Admin\py\hey.py:26: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '33': [33, 3] [33 ,9] [33, 15] [33,16] [33, 19] [33,21] [33,23] [33, 24] [33 ,30] [33, 31] [33, 32), C:\Users\Admin\py\hey.py:27: SyntaxWarning: list indices must be integers or slice s, not tuple; perhaps you missed a comma? '34': [34,9] [34, 10] [34, 14] [34, 15] [34, 16] [34 ,19] [34,20] [34, 21] [34 23] [34 ,24] [34 ,27] [34, 28] [34, 29] [34, 30] [34, 31] [34, 32] [34, 33] Traceback (most recent call last): File "c:\Users\Admin\py\hey.py", line 4, in '3' : [3, 1] [3,2], TypeError: list indices must be integers or slices, not tuple PS C:\Users\Admin\py> |

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!