'constantly checking if a condition is true or false

I'm new to python and programming in general and I am currently taking a course on Udemy. One of the projects is to create a pick your own adventure game. I've been doing pretty well until I came across something that has been picking at me. I wanted to display text depending on whether or not you have died by changing the condition of death from False to True. I know I can just add you died after the if/else statement with a print function but I wanted to make it a bit more challenging. Here's an example.

death = False
if death == True:
  print("\nYou died")

choice_1 = input("left or right:\n")
if choice_1 == "left":
  death = False
  print("*The next piece of dialogue*")
else:
  death = True
  print("*The next piece of dialogue*")

It would then print "you died" after the next piece of dialogue if the death changed to True.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source