Hello people! New guy here. I recently started learning Python (won't bore you with my story) and decided to make a little game. It's quite simple, based on a question - answer logic. I was hoping to receive some feedback from experienced programmers in order to make better code in the future.

print "This is a simple game. You only have to write your choice. It's up to you to survive or die trying. You can type in \"stats\" at any time in order to get your current stats printed out on the screen. Have fun!"def wilderness():

energy = 50 food = 0

if energy <= 0: dead()

print "You wake up and find yourself in the wilderness. You have two choices:" while True: print "1. Go towards the lake to the right" print "2. Go in the forest to the left"

if ("lake" in answer) or ("drink" in answer) or ("Drink" in answer): lake(energy, food) elif ("water" in answer) or ("Search" in answer) or ("search" in answer): water(energy, food) elif "forward" in answer: forward2(energy, food) else: print "There's no time to waste. Choose fast!"

print "After eating a proper meal, you got yourself some fancy clothes. Next destination: the king!"

king(energy, fancy)

def king(en, fc):

energy = en fancy = fc

if energy <=0: dead()

if fancy == 0: print "The king won't talk to a beggar like you! After getting beaten up, you manage to get back into the castle." castle(en, mn) else: print "The king will talk to you now!" kings_room()

def kings_room():

print "You got to the king. He is very displeased with your presence. What are you going to do?" while True: print "1. Assault him" print "2. Beg for mercy"

answer = raw_input("> ")

if "assault" in answer: win() elif "beg" in answer: prison() else: print "There's no time to waste. Choose fast!"

def win():

print "After assaulting the king, your memory came back to you and you realised that actually you are the true king. Congratulations! You won!" while True: print "Do you want to play again? Y/N"

More importantly though... the structure of your program is unusual. Typically, a high-level function does something, returns, and then you use that return value in subsequent lines of the program. Instead, in your program, you never let functions return, but instead just keep calling the next function. What I like to do with my programs is have a main() function that has some high level functions that I call one after another, so that a reader of the program at a high level knows what's going to happen. In your program, if I want to know how to get to a specific place, I have to look at where it's call, then where that's call, then where that's called... you just seem to have developed bad habits writing a large program before you understood things well (not meant as criticism as much as feedback; after all, you had the initiative to do this whole thing).

Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from