todos = []
print(“Welcome to todo app”)
while True:
print(“What do you want to do? “)
user_action = input(“‘add’, ‘show’, ‘edit’ , ‘delete’ or ‘exit’: “).lower().strip()
match user_action:
case ‘add’:
todo = input(“Enter a todo: “)
todos.append(todo)
case ‘show’:
i = 1
for item in todos:
print(f”{i}. {item}”)
i += 1
case ‘edit’:
edit_todo_index = int(input(“Enter number of todo which you want to edit: “))
# todos[editing_todo_index] = input(“Enter new todo: “)
todos.setitem(edit_todo_index – 1, input(“Enter a new todo: “))
case ‘delete’:
todo_index = int(input(“which todo you want to delete: “))
deleting_todo = todos[todo_index – 1]
todos.remove(deleting_todo)
print(f”todo ‘{todos[todo_index – 1]}’ wad deleted successfully”)
case ‘exit’:
break
if len(todos) > 0:
print(f”n$$$ Todo app was created Successfully $$$n”)
else:
print(f”n$$$ todo app is empyt $$$n”)
I tried to case “delete”
in print function list indexing not working as expected
print(f”todo ‘{todos[todo_index – 1]}’ wad deleted successfully”)
todos[todo_index – 1] not calculating the todo_index – 1 formula
user26745043 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.