0

I want to make variables(names) to each elements in list to callable objects for later use:

positions = [[610, 85], [770, 85], [930, 85],
             [610, 245], [770, 245], [930, 245],
             [610, 405], [770, 405], [930, 405],
             [690, 565], [850, 565]]
position_1 = positions[0]
position_2 = positions[1]
.
.
.    
position_11 = positions[10]

I've try to assign to an f-string but f-string is not callable.

for i, pos in enumerate(positions):
    f'position_{i+1}' = pos[i] #Not working.

I know I can do something like

position_1, position_2, ....position_11 = positions

but it's pretty inefficient. The real data contains way too much to key in manually.

Cookie
  • 135
  • 8

0 Answers0