0

After creating some loop variables with exec, I dont know how to put them in a list, see below

for i in range(2):
   exec("x%i=i"%i)  #Here I created the variables x0 and x1
   y.append(??????) #I dont know how to put the above variables inside this list in the same loop
print(y) 
  • Possible duplicate of [python: get the print output in an exec statement](https://stackoverflow.com/questions/3906232/python-get-the-print-output-in-an-exec-statement) – user3483203 Mar 11 '18 at 01:51
  • Did you try this https://stackoverflow.com/questions/4906977/access-environment-variables-from-python? – TigerTV.ru Mar 11 '18 at 01:53

0 Answers0