From 3c72af8ff60196f87a5d0b1fd4aa321a2577fc48 Mon Sep 17 00:00:00 2001 From: mau Date: Fri, 19 Jun 2026 17:56:27 +0200 Subject: [PATCH] add: add repr method --- lru_cache.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lru_cache.py b/lru_cache.py index aba1c89..c9c08c6 100644 --- a/lru_cache.py +++ b/lru_cache.py @@ -4,6 +4,9 @@ class LRUCache: self.capacity = capacity self.slots = [] + def __repr__(self): + return ", ".join(map(lambda x: str(x), self.slots)) + def get(self, key: int) -> int: if key <= len(self.slots) -1: return self.slots[key] @@ -21,7 +24,10 @@ def main(): print(cache.get(0)) cache.put(0,1) - print(cache.get(0)) + print(cache) + + cache.put(1,2) + print(cache) if __name__ == "__main__": main() \ No newline at end of file