-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (43 loc) · 1.58 KB
/
Copy pathmain.py
File metadata and controls
51 lines (43 loc) · 1.58 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
store={}
while True:
cmd = input(">>>")
if cmd.lower() == "exit":
print("BYE")
break
else:
print(f"You typed {cmd}")
parts = cmd.split(maxsplit = 2)
if not parts:
continue
parts[0] = parts[0].upper()
if parts[0] == "SET":
if len(parts) == 3:
store[parts[1]] = parts[2]
print("Stored the Parts")
elif len(parts) > 3:
parts2 = cmd.split(maxsplit = 2)
store[parts2[1]] = parts2[2]
else: print("Wrong Number of Arguments")
elif parts[0] == "GET":
if len(parts) == 2:
output = store.get(parts[1], "nil")
print(output)
else: print("Wrong Number of Arguments")
elif parts[0] == "DEL":
if len(parts) == 2:
if parts[1] in store:
temp = parts[1]
temp2 = store.get(parts[1], "nil")
del store[parts[1]]
print(f"{temp} was deleted, and the content {temp2} inside it")
else: print("NIL")
else: print("Wrong Number of Arguments")
elif parts[0] == "KEYS":
if len(parts) == 1:
print(" ".join(store.keys()))
else: print("Wrong number of arguments")
elif parts[0] == "EXISTS":
if len(parts) ==2 :
print(1 if parts[1] in store else 0)
else: print("Wrong Number of Arguments Inputted")
else: print("The wrong command was inputted")