0

I wanted to split lists from the dictionarie into separate elements and append it into a new list

graph = {0 : [1],
         1 : [2, 3],
         2 : [2],
         3 : [0]
}

visited = []
for i in graph.values():
    if i not in visited:
        visited.append(i.split(','))
        
print(visited)

I am getting this if I simply print the i

[[1], [2, 3], [2], [0]]

But I basically want to split it into separate elements, so I can get unique values like this:

[1, 2, 3, 0]

But I'm getting an error that list doesn't have an attribute split

0 Answers0