На
def determine_gift(good, evil, last_gift):
if good > evil and last_gift == "добрый":
return "серебряный шиллинг"
elif evil > good and last_gift == "злой":
return "золотой"
else:
return "Ах, не знаю!"
def main():
while True:
good, evil = 0, 0
last_gift = None
while True:
line = input().strip()
if line == "":
return
if line == "добрый":
good += 1
last_gift = "добрый"
elif line == "злой":
evil += 1
last_gift = "злой"
elif line == "Какой подарок?":
print(determine_gift(good, evil, last_gift))
break
if __name__ == "__main__":
main()
вот код:
while True:
good = 0
evil = 0
gift = None
while True:
line = input()
if line == "":
break
if line == "добрый":
good += 1
gift = "добрый"
elif line == "злой":
evil += 1
gift = "злой"
elif line == "Какой подарок?":
if good > evil and gift == "добрый":
print("серебряный шиллинг")
elif evil > good and gift == "злой":
print("золотой")
else:
print("Ах, не знаю!")
break
if line == "":
break