I keep getting a syntax error when using += in python here is my code. I am also having troule with nonlocal. I am getting lots of errors including syntax errors and unbound local error Thanks in advance!!!
update: more code added this is all the code It now says local variable 'citizens' referenced before assignment
from time import sleep as slp
import time
import sys
def clear():
print("\033[2J\033[H", end="")
def slow(text, endl="\n"):
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.05)
print(endl, end="")
def slow_in(prompt=''):
slow(prompt, endl="")
return input()
import random
def generate():
import random
slow("generating random circumstance...")
slp(2)
slow("done")
rd = random.randint
money = rd(1, 100)
health = 100
global citizens
citizens = rd(10000, 1000000)
supporters = rd(1,1000000)
def show():
print("money-" + str(money))
print("health-" + str(health))
print("citizens-" + str(citizens))
print("suppporters-" + str(supporters))
waysod = [""]
def death():
wod = random.choice(waysod)
rnum = rd(1,citizens//2)
citizens -= rnum
print(str(rnum) + " citizens died " + wod)
return citizens
import random
rd = random.randint
slow("Welcome to presidential nightmare! ")
from time import sleep as slp
slp(.6)
slow("The easiest thing to do in this game is, well...")
slp(.8)
slow("destroy the country!!")
slp(.6)
slow("lets get started!!!")
slp(.6)
slow_in("press enter to continue...")
generate()
show()
death()