Classe stack, usa list
Classe La nuovo struttura dati utilizza una lista (list) class Stack: def __init__(self): self._lista=[] def push(self, x): self._lista.append(x) def pop(self): return self._lista.pop() def is_empty(self): return (len(self._lista) == 0) Test 1 stack=Stack() # [] stack.push(18) # [18] stack.push(1) # [18, 1] stack.push(28) # [18, 1, 28] print(stack.is_empty()) # False print(stack.pop()) # [18, 1] 28 print(stack.is_empty()) # … Leggi tutto