Code Review: My first Python Game

Around exercise 35 I was listening to a contest on the radio where you win an amount of money and then have to decide whether to risk it all and see what’s behind the next “door”. Figured I had the python knowledge to make that game and gave it a whirl.

Would love any feedback on the code. I originally tried a while-loop but couldn’t get it working correctly.

Thanks,
Mike

1 Like

Hey @lobot1 I played your game. Have not looked at the code yet I guess the number of doors is random, right? and then the game is about guessing when to leave before loosing everything right?

It was cool, again I have not looked at the code at all but enjoyed giving it a try :slight_smile:

Will probably share more after seen the code behind it.

@lobot1 I actually read your code and the only thing that crossed my mind while looking at it is that I would have put the variables the print the design (i.e: thanks, over, sorry, etc ) on a separate file just for readability that way all those long things distracting from the logic would be put a part but other than that all seem cool.

Thanks @ricarod for looking (and playing).

I had thought about putting the graphics in a text file(s) to get them out of the way.

The mechanic is pretty basic. In each room a random number (1-100) is generated and some luck is added from another, smaller random number. An if statement checks if the generated number is below the room’s risk level. Each room you proceed to increases the room’s risk level.

yeah nice!, I had fun with it.

Mate haven’t tried it as I’m buggered but like the code and the concept. Look forward to seeing it develop as you go through the book. Cheers

You can put a while loop after it asks yes for user input.

result = True
while result not True 
    user input == yes or finished
    result = False
    else result = True #breaks loop

Will the while ever execute at all?

It was an example, if it doesn’t work, alter it. I am having had a few day off my laptop which I code on, so if the logic is wrong then it’s only a Boolean. Change it as there are only two options, it’s either true or false. Therefore I can not answer your question. Have a lovely weekend. Cheers tc :slightly_smiling_face:

ah I see what you mean, I shouldn’t read when I’m tired. Yeah, I wouldn’t have run.

while not result

^^ that’s what I was meant to type. What I was trying to get across is that the user input stalls the loop allowing you to keep it going or stop it. Happy days :sunny: