-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskript.txt
More file actions
34 lines (27 loc) · 825 Bytes
/
skript.txt
File metadata and controls
34 lines (27 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Repository:
def __init__(self):
self.data = {}
def save(self, key, value):
self.data[key] = value
def get(self, key):
return self.data.get(key)
def delete(self, key):
if key in self.data:
del self.data[key]
def update(self, key, value):
if key in self.data:
self.data[key] = value
else:
raise KeyError("Key not found")
def list(self):
return self.data.items()
# Example usage:
repo = Repository()
repo.save("key1", "value1")
repo.save("key2", "value2")
print(repo.get("key1")) # Output: "value1"
repo.update("key1", "new value")
print(repo.get("key1")) # Output: "new value"
repo.delete("key1")
print(repo.get("key1")) # Output: None
print(repo.list()) # Output: dict_items([('key2', 'value2')])