How to convert GUID to other type in Python script

It works! But I don’t understand what’s the difference with your code and mine.
in line 15, for i in range(len(edges)), my code got error like the second image I uploaded.
your code doesn’t raise error despite it’s literally same with mine. Can you explain it to me?