Is there a better way of doing this in python 3:
point, edges = edges_per_point.popitem()
edge = edges[0]
if len(edges) > 1:
edges_per_point[point] = edges[1:]
I wish to begin with any edge in the dict while also removing it from the dictionary. I also which the list to be removed when it becomes empty.
If I understood your question right and shamelessly coping one of the deleting-during-iteration way of Lennart Regebro.
I’ll do it like this: