0
i = 0
loc_file = []
open_file=open('test.txt','r')
file_lines=open_file.readlines()
file = file_lines[0].strip()  # First Line
for _ in (file_lines[1]):
  exec(f'c{i} = _')
  loc_file.append()
  i = i + 1
print(loc_file)

I am trying to use variables as they are assigned in as little code as possible, but nothing I have tried to put for

loc_file.append()

has seemed to work.

Eden
  • 1
  • 1
    Instead of a list of variables named `c0`, `c1`, `c2` ... just use one list called `c` and access like `c[0]`, `c[1]`, `c[2]`... – wim Jun 08 '22 at 18:19
  • What is `loc_file` and what do you want to append to it? Also see answers to this [question](https://stackoverflow.com/questions/1373164/how-do-i-create-variable-variables) – quamrana Jun 08 '22 at 18:20

0 Answers0