'How to change a class of edges to a list in NetworkX?

I tried to create a list from the class of edges in NetworkX using the function list(). However, when I access the list using print(data[0]), I get the edge and all its attributes but I only want the edge. How can I access the edge alone?

edges = g.edges()
print("Type = " ,type(edges))
      
print("All edges: ", edges )

#Changing the class of edges into a list
data = list(edges. items())

print("First edge = ", data[0])

This is the output of the code: enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source