stack = ['','','','','','']
global first
global last
first = 0
last = 0
print(stack)
while True:
def push():
if 0 <= last:
stack[last] = 'D'
last = last + 1
if last == 6:
last = -1
else:
print("The stack is full.")
print(stack)
def pop():
stack[last] = ''
last == stack[last-1]
print(stack)
if first == last:
print("The queue is empty")
a = input("Push or pop. ")
if a == 'push':
push()
elif a == 'pop':
pop()
I've assigned last as a global variable yet I get this error UnboundLocalError: local variable 'last' referenced before assignment. Considering I've made last a global variable I don't understand why the error is suggesting otherwise, any solutions?