I strongly discouraged you to use locals()
(or globals()
or vars()
) to manipulate the variables dynamically:
list_1 = ['File_A', 'File_B', 'File_C', 'File_D']
for v in list_1:
locals()[v] = np.array(0)
Output:
>>> File_A
array(0)
>>> File_B
array(0)
>>> File_C
array(0)
>>> File_D
array(0)
Note: File_A
, File_B
, … should be valid Python name identifiers.
CLICK HERE to find out more related problems solutions.