Advertisement
Guest User

conctact_books.py

a guest
Oct 2nd, 2022
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. from notifypy import Notify
  2.  
  3. notification = Notify()
  4.  
  5.  
  6. usernames = []
  7.  
  8. while True:
  9. prompt = input("> ")
  10.  
  11. if prompt.startswith("add"):
  12. command = prompt[4:]
  13. usernames.append(command)
  14. print(usernames)
  15. elif prompt.startswith("remove"):
  16. command = prompt[7:]
  17. if command in usernames:
  18. usernames.remove(command)
  19. print(usernames)
  20. else:
  21. print("This username does not exist in the list.")
  22.  
  23. elif prompt.startswith("replace"):
  24. command = prompt[8:]
  25. if command not in usernames:
  26. print("This user does not exist in the list. ")
  27. continue
  28. else:
  29. pass
  30. new_val = input("with: ")
  31. usernames.remove(command)
  32. usernames.append(new_val)
  33. print(usernames)
  34. print("")
  35. notification.title = 'Replaced Complete'
  36. notification.message = "Successfully replaced " + str(command) + " with " + str(new_val)
  37. notification.send()
  38.  
  39. elif prompt == "list":
  40. print(usernames)
  41.  
  42. elif prompt.startswith("exit"):
  43. break
  44. else:
  45. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement