List indexes

Asked

Viewed 36 times

1

Good afternoon, this week my teacher passed me the question of scheduling a phone book. I did with dictionary but he had me redo with lists.

There’s a part where I have to remove a contact from the phone book and his number. But I don’t know how to remove the name that is an unknown index. If I can find the index of the name, it is easy to remove the index of the number. But how do I find the name index?

agenda = []
while True:
    print("=================")
    print("Agenda INTIN")
    print("=================")
    print("Menu de opções:")
    print("1 - Cadastrar novo contato")
    print("2 - Buscar contato")
    print("3 - Alterar contato")
    print("4 - Excluir contato")
    print("5 - Listar todos os contatos")
    print("6 - Sair")
    print("----------------------------")
    opcao = int(input("Digite uma opcao: "))
    if(opcao == 4):
        busca = input("Digite o nome do contato que deseja excluir: ")
        if(busca in lista == True):
            agenda.remove("busca")
            agenda.remove(
            print("Contato excluido com sucesso")
        else:
            print("ERROR")
            print("Contato inexistente")
        print("----------------------------")
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.