Loop de retângulos svg do banco de dados

Estou lendo retângulos svg de um banco de dados usando python, não sei se esse é o caminho certo, pois parece que estou codificando, isso porque quero que cada retângulo mude de cor na minha folha de estilo css. Existe uma maneira melhor de chamar esses retângulos em vez de usar ifs e elifs, porque se eu tiver 100 retângulos, qual é a melhor maneira de fazer isso? Eu adicionei minha folha de estilo também

for row in c: 

 box_x = ((row[3]-row[1])/2 + row[1] - 0.25)
 box_y = ((row[4]-row[2])/2 + row[2] - 0.25)
 move1 = box_y * 2
 try1 =  row[1] * 2  

 if row[0] == 1:
    print('<rect id= rectangle1 class= "rectangles" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 2:
    print('<rect  id="rectangle2" class= "rectangles"   onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 3:
    print('<rect  id="rectangle3" class= "rectangles"  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 4:
    print('<rect id="rectangle4" class= "rectangles" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 5:
    print('<rect id="rectangle5" class= "rectangles"  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 6:
    print('<rect id="rectangle6" class= "rectangles"  onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 7:
    print('<rect id="rectangle7" class= "rectangles"  onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 else:
    print('<rect id="rectangle8" class= "rectangles"  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')

folha de estilo css

.rectangles{
        fill:       #ff3333;
        stroke:     #000000;
        stroke-width:   0.1; 

}
#rectangle1:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #A52A2A;
}  
#rectangle2:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #A52A2A;
}
#rectangle3:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #006400;
}
#rectangle4:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #000000;
}
#rectangle5:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #006400;
}
#rectangle6:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #000000;
}
#rectangle7:hover{
        stroke:     #FF7F00
        stroke-width:   0.1;
        fill:       #FFFFFF;
}
#rectangle8:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #FFFFFF;
}

questionAnswers(1)

yourAnswerToTheQuestion