Please help me. I wanted the counter num variable to add everytime the function is ran. But its not working, please tell me why I did wrong. If I use return num then the code is ending which I dont want, but n =+1 is not working, please help. Thanks a lot.
def prompt():
num = 1
print(num)
question = input("Do you want to add a file(y,n): ")
if question == "y":
file = input("Which File?: ")
nukefile.append(file)
st_frm = input("Start frame: ")
start_frame.append(st_frm)
en_frm = input("End Frame: ")
end_frame.append(en_frm)
#return num + 1
num =+1
print(num)
nukew = str("start /wait Nuke11.1.exe -x -"+st_frm+"-"+en_frm+" "+file)
nukewrite.append(nukew)
que = (str(num)+". "+file+"--"+st_frm+","+en_frm)
for_artist.append(que)
for x in for_artist:
print(x)
prompt()
return num
elif question == "n":
print(nukewrite)
f = open(batchfile, "a")
for shotsa in nukewrite:
f.write('\n'+shotsa+'\n')
print("Following files will render:")
for shotsb in nukefile:
print(shotsb)
f.close()
else:
print("Invalid entry")
prompt()
If you want to count how many times the function runs and keep it recursive, you'll need to define prompt.num
outside of prompt
. You can define it under the function or use a decorator and define it above.
def prompt():
prompt.num += 1
your code
prompt.num = 0