I'm getting errors while declaring a global variable. I defined a global variable inside a definition.
import os
import time as t
s = t.time()
import numpy as np
#print(os.getcwd())
#print(os.listdir(os.getcwd()))
chDir = os.chdir("/storage/emulated/0/OS-TEST-FOLDER")
print(chDir)
#print(dir(os))
file = open("Times.txt",'w')
tann = []
def tanns():
while True:
epochs = int(input("Enter how many epochs please >>> "))
for i in range(epochs):
aa = np.tan(i)
print(f'Writing Tan{i} in Process')
aaa = f'tan {i} degree = {aa}'
# t.sleep(0.01)
tann.append(aaa)
#with open(file) as f:
file.write(str(tann))
#print(file)
f = t.time()
dur = f - s
print(f'Finished writing {epochs} tan')
print(f"The Program Finished in {dur} seconds ")
global choice = str(input("Do you want to continue running the Program >>> "))
if choice == "n":
break
if choice == 'y':
tanns()
This was the error I got when I ran this code.
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 34
global choice = str(input("Do you want to continue running the Program >>> "))
^
SyntaxError: invalid syntax
[Program finished]