I am not going to discuss in great length the unnecessary use of global variables here (it would be better to pass a/b as parameters).
The syntax you used (if global b>global a:
) is invalid. The global x
is a definition of the scope of a variable, it is done once and should be on its own line.
The correct syntax should be:
import random
import sys
a=random.randint(1, 30)
b=random.randint(1, 30)
c= "minus" or "plus" ## not sure what this is doing
print(c)
def f():
global a ## definition of global scope
global b
if b>a: ## use of variables
a=random.randint(1, 30)
b=random.randint(1, 30)
print(a+b)
and presumably you want to call f
at some point:
f()