-1

I have a folder dir_in containing set of files and supplied another list var with possibly variable names for the files.

dir_in = 'my_files/data/' contains

fileA.txt

fileB.txt

fileC.txt

var = ['A', 'B', 'C']

I wish to iteratively assign each variable in var to it's respective file in dir_in such that I get that file each time the variable is called. E.g. A = fileA.txt Any hints here please?

AAAmali
  • 1
  • 1
  • This is a bad idea. See the comments on [How do I create variable variables?](https://stackoverflow.com/questions/1373164/how-do-i-create-variable-variables). I suggest using a _dictionary_ instead of creating variables in the global scope, as the top answer there demonstrates – Pranav Hosangadi May 06 '22 at 17:06

0 Answers0