Exercise 30, game over function?

Hi there.

I just went through the little game on exercise 30, it was fun. I would like to take it a little further and create a game over when the player selected an option.

I think I will have to make the game into a function, and also create another function for the game over.

But, Iโ€™m not there yet to do it on my own. Any ideas as to where to start making the game over function for exercise 30. Nothing fancy :smiley:

Hi. Iโ€™d suggest carrying on with the book. You get to write the game a few more times :wink:

1 Like

Thanks ! @gpkesley

Iโ€™m truly enjoying the book. I have been complementing it with other courses like codeacademy and itโ€™s fun to have been learning from different approaches.

If you want to just keep track of what the user is doing the simplest is to make a global dict like this:

STATS = {}

Put that at the top, then when you wan to track anything in a function do this:

STATS["hp"] = 10

The other way is to use globals, but that gets hairy after a bit.

1 Like

Thanks Zed.

I was learning about dictionaries on another course. Super cool, not there yet, but I can see how they work.

1 Like