I need to loop over a range of a variable and run 3 python scripts each of which uses the said variable. Currently I can run the 3 scripts without being able to loop thru the range of variable that the called scripts need. i currently have the following code:
import subprocess
cmd='python foo.py'
p=subprocess.Popen(cmd,shell=True)
out,err=p.communicate()
cmd='python bar.py'
p=subprocess.Popen(cmd,shell=True)
out,err=p.communicate()
cmd='python bas.py'
p=subprocess.Popen(cmd,shell=True)
out,err=p.communicate()
but what i need is something like the below:
for x in range(1, 11):
cmd='python foo.py'
p=subprocess.Popen(cmd,shell=True)
out,err=p.communicate()
cmd='python bar.py'
p=subprocess.Popen(cmd,shell=True)
out,err=p.communicate()
cmd='python bas.py'
p=subprocess.Popen(cmd,shell=True)
out,err=p.communicate()
how can i pass x into foo, bar and bas and loop over the range of x? thank you for your help!