1from typing import TypeVar, Generic
2
3T = TypeVar('T')
4
5class Stack(Generic[T]):
6 def __init__(self) -> None:
7 # Create an empty list with items of type T
8 self.items: List[T] = []
9
10 def push(self, item: T) -> None:
11 self.items.append(item)
12
13 def pop(self) -> T:
14 return self.items.pop()
15
16 def empty(self) -> bool:
17 return not self.items
18