0

I have an a.py file, which stores multiple list inside.

total_list = 2

a0 = ['example_string','example_string2']
a1 = ['example_string4','example_string3']

and I have a b.py which will read the list fron a.py. I want to do something like this which is able to loop to get each of the lists in a.py.

import a

for i in range(a.total_list):

 steps = "\n".join(a.a+str(i))
 print(steps)

and I get this error

AttributeError: module 'a' has no attribute 'a'

I had tried the globa() and local() methods but it is not working.

petezurich
  • 9,280
  • 9
  • 43
  • 57
yyii mm
  • 19
  • 2
  • 1
    you might consider making `total_list` a list of list variables: [https://onlinegdb.com/oyIBRiMDl](https://onlinegdb.com/oyIBRiMDl). – richard Jun 25 '23 at 07:00

0 Answers0