Help! I don't get booleans!

Ok, so we made a bool function that asks if the player didn’t want to play again…Why do we use another “wantstoplayagain” bool…which is an actual bool instead of the return value of the function? And if we can and I’m just being stupid then please inform.

Hi there @JoliJimi
First thing first, you’re not stupid. That’s a very valid point. :slight_smile:

There is nothing wrong, syntactically, with writing it to return True if the statement/code block is true and false otherwise. However, this could make it a bit dangerous as you could end up with two returns in your function. Or a ternary statement that’s difficult to debug/read.

So think of it like this: it’s done to make it easier to reread 6 months from now so you can understand what’s happening.

1 Like

Privacy & Terms