I am running multiple scripts in sequence according to the list I and the following executable. However, when one of the script in folder (say, 2) runs into an error, it terminates instead of moving to folder 3. Basically I want the executable to move onto the next script if there is an error in the present script. How do I do this?
I=[1,2,3]
for i in I:
exec(open(rf"C:\5100 nodes\{i}\5100_beta_0.01_50.0_1.0ND_3.py").read())
The error encountered while running script in folder 2 is
File "<string>", line 618, in <module>
ValueError: max() arg is an empty sequence
>Solution :
You could use a try-except block.
I=[1,2,3]
for i in I:
try:
exec(open(rf"C:\5100 nodes\{i}\5100_beta_0.01_50.0_1.0ND_3.py").read())
except Error as e:
print(e)