4
I have a question in my code of Death Note where I can’t create a loop to ask if the notebook user wants to kill someone else and the code should be closed when the user no longer wants to kill someone. Someone there gives me a force I swear not to write the name on Death Note.
Observing: In the anime Light Yagami when it does not define the death of the person that person dies automatically from cardiac arrest and in the if morte == ' '
does not enter this condition, what would be the problem?
usuario = str (input("Digite o nome do usuário do caderno: "))
print ("Bem vindo ao Death Note {}".format(usuario))
print ("Deseja matar alguém? ")
resposta = str (input("S - Sim | N - Não: "))
if resposta == 'S' or resposta == 's':
nome = str (input("Digite o nome da vítima: "))
morte = str (input("Digite a causa da morte: "))
if morte == ' ': # Não funciona essa condição
print ("O nome da vítima é {}".format(nome))
print ("E morreu de uma parada cardíaca!")
else:
print ("O nome da vítima é {}".format(nome))
print ("Causa da morte: {}".format(morte))
print ("Deseja matar mais alguém {}?".format(usuario)) '''
outramorte = str (input("S - Sim | N - Não: ")) Loop sentinela
'''
else:
print ("{} volte quando quiser para limpar o mundo!!!".format(usuario))
First I think the suicide check is
nome == usuario
, Knowing this you can solve the Obs 2 putting aif
before the print checking if thenome!=usuario
so he just givesprint
if the last name is different, another solution is you create another variable to save the type of the last death, another thing: when it is suicide you may also have to skip theresposta = (input...
and put asN
=)– Icaro Martins
@Icaromartins I got a little lost
– user141036
Hello @alex, I believe original problem (Death Note in Python - Loop Sentinel of Death) was solved by one of the answers below. Note that the last editions made the answers lose context, the ideal now would be you revert to (s) edition(s) (accept the answer that helped you in the original problem) and create a new question and if you need to add context to the new question add a link to this. = D
– Icaro Martins
I still don’t understand the solution even with the answers below, some of them really helped me in some details of my code but the focus of the problems I edited still not because suddenly I wanted to implement the code thinking of some that made sense similar to Death Note in the anime.
– user141036
In other words, I thought about some improvements in the code and I didn’t understand how you make these improvements in coding.
– user141036
I reversed your post because it invalidates the answers given. Please read [tour] and [help] to better understand the website model.
– Bacco