from typing import Self class Node: def __init__(self, data: int): self.data: int = data self.next: Self | None = None class LinkedList: def __init__(self): self.head: Node | None = None # Definition der "append" Methode ich mag push und pop lieber >:) def push(self, data: int): if self.head is None: self.head = Node(data) return node = self.head assert node is not None while True: if node.next is None: node.next = Node(data) return node = node.next def pop(self) -> int | None: if self.head is None: self.head = None return None node = self.head assert node is not None while True: if node.next is None: return node.data node = node.next def print(self): node = self.head while node is not None: print(node.data) node = node.next