if admin.isUserAdmin(): # This is on zero indent it's not inside a function or any other block
if n == 0:
global nzero
nzero = df.to_string()
print(nzero)
elif n > 0:
global ntrue
ntrue = df.head(n).to_string()
print(ntrue)
while live_update:
if n == 0:
global nzero2
nzero2 = df.to_string()
print(nzero2)
elif n > 0:
global ntrue2
ntrue2 = df.head(n).to_string()
print(ntrue2)
print(nzero) #error nzero is not defined
I have much more complicated code but for the sake of convenience I've simplified things.
In the above program I want to make nzero, nzero2, ntrue and ntrue2 global that is it should be available outside the if block. but when I use it outside it gives me error saying nzero is not defined same is for nzero2, ntrue, ntrue2