0

I am showing a subsection of the code where i am defining two functions defining_polygon_outside_nest and defining_polygon_inside_nest. err is an integer whose values ranges from [0,5]. I define err as a global variable within these functions and want to use this to add specific values in list ants_inroi_outsidenest and ants_inroi_insidenest. Whenever i do this, i am getting an error if for_coordinates_inside_nest((x,y)) is True and err==0: NameError: global name 'err' is not defined. It works fine if i am not using err in function defining_polygon_inside_nest Any suggestions to solve this?

err = 0
def defining_polygon_outside_nest(tag_data):
    global err
    ants_in_arena = []
    ants_inroi_outsidenest = []
    for id, (x,y) in tag_data:
        ants_in_arena.append(id)
        if for_coordinates_outside_nest((x,y)) is True and err==0:
            ants_inroi_outsidenest.append(id) 
    return ants_inroi_outsidenest


def defining_polygon_inside_nest(tag_data):   
    global err
    ants_in_arenai = []
    ants_inroi_insidenest = []
    for id, (x, y) in tag_data:
        ants_in_arenai.append(id)
        if for_coordinates_inside_nest((x,y)) is True and err==0:
            ants_inroi_insidenest.append(id)
    return ants_inroi_insidenest
Venkat kamal
  • 279
  • 2
  • 3
  • 8

0 Answers0