I have been studying Python and trying to create a simple telephone book. However, I can't solve how to delete an item by using an index. Here is the code that doesn't work:
number = 1
while number < len(book):
for x in book:
print("{}) NAME: {} NUMBER: {} ".format(number,x,book[x]))
number = number + 1
delete = input("Insert the number you want to delete\n")
delete = int(delete)
book.pop(delete - 1)
This code can successfully list all of the contact information in the phone book, but I cannot find any way to delete the items. I think it'd be impractical to insert the name of the person whom you want to delete.
Is there any alternative that I can do? Thank you so much.