repl.it
Python

No description

fork
loading
Files
  • main.py
  • db.py
  • Packager files
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.py
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
import replit

import db

key = input("key: ")
while True:
  replit.clear()
  lst = db.get(key)
  if lst:
    for i, elem in enumerate(lst, 1):
      print(f"{i} - {elem}")
  else:
    print("list is empty")
  
  op, *args = input("> ").split(" ")
  if op == "add":
    lst.append(" ".join(args))
    db.set(lst, key)
  elif op == "clear" and len(args) == 0:
    db.set([], key)
  elif op == "remove" and len(args) == 1:
    pos = int(args[0]) - 1
    del lst[pos]
    db.set(lst, key)
  elif op == "change" and len(args) == 1:
    db.change_key(key, args[0])
    key = args[0]
  elif op == "done":
    replit.clear()
    break