I am working in python 3 and I encountered this problem in my code. I wanted to use a variable in a from x import x function inside a loop so that the file being imported from could change without making a bunch of code for each file.
Here is my code:
for x in range(0, 1):
variable_name = "test"
from variable_name import *
When I run the code, I get an error: No module named 'variable_name'. I want it to read the variable value as being the filename, not the variable name. Is there a way to fix this?