0

I'm not sure why my program doesn't enter the for loop at all, the code is below:

    ### Retrieve and edit polygons
    def buttonEdit():
        for line in myFile:
            ptList = line.strip('[]').split(',')
            for pt in range(1, len(ptList)):
                t.pendown()
                t.goto(ptList[pt][0], ptList[pt][1])

    ### Store polygons in a file
    while True:
        try:
            myFile = open("polygon_data.txt", 'a+')
            break
        except OSError:
            print("File does not exist, please try again!")
halfer
  • 19,824
  • 17
  • 99
  • 186
Albert
  • 1
  • 1
  • 1
    The posted code never calls the `buttonEdit` function, so of course no `for` loop is ever run – ForceBru Apr 09 '22 at 14:25
  • Where is the function getting `myFile` from? Are you sure there is data in it and the file pointer is at the beginning of the file? (Perhaps the `for` loop over a file automatically starts at the beginning, but I'm not sure) – RufusVS Apr 09 '22 at 16:08

0 Answers0