Random Event and Health 

We need to hold a health value for the player and one way to do this is to declare a global variable to hold it. 

On the example below I have used random numbers - so imported random at the top 

Then I have declared a global variable called health and assigned the value 100 to it 

Then I added to my cave definition - if the player looks (it is dark) they see nothing but have a 50% chance of banging their head on the roof and losing 10 health points.  My whole code for the amended cave() definition is below - I commented the code (# and red text)  to help show what it does. 

You could write another print statement to say what their current health is. 

You could use this principle to decide on an enemy or not being there or a different type of enemy being there.