====== 8. Zásobník ====== class Stack: def __init__ (self): self.items = [] # prazdny seznam pro udzovani dat def push (self, data): self.items += [data] def pop (self): return self.items.pop() def is_empty (self): return self.items == [] def size (self): return len(self.items) s = Stack() s.push (10) s.push (30) s.push (40) while s.is_empty() is not True: print (s.pop()) text = 'TE*A*QYS***SEU****NI*O**' z = Stack() for x in range(len(text)): # print (text[x], end=' ') if text[x] >= 'A' and text[x] <= 'Z': z.push(text[x]) if text[x] == '*': print(z.pop(), end='') print() text = '((()()))' w = Stack() for x in range(len(text)): if text[x] == '(': w.push(text[x]) if text[x] == ')': print('{}-{}'.format(x, w.size())) if w.is_empty() or w.pop() != '(': print(w.is_empty()) print('nevalidni') if w.is_empty() is not True: print(w.is_empty()) print('nevalidni')