new to While statements

2013-08-06 Thread krismesenbrink
import random



def room ():

hp = 10
while hp != 0:

random_Number = random.randint(1, 2)

#asking if you want to roll/play
des = input("Would you like to roll the die?")

if des == ("y"):
print ("Rolling the die...")
print ("You rolled a...")
print (random_Number)

#a "monster" appers if you roll a 1""
if random_Number == 1:
monster_hp = 10
print ("Oh no a Monsster!")
print ("would you like to attack?")
answer = input("y or n?")
if answer == "y":
#if you choose to battle this is what happens
while monster_hp >=0:
print ("you attack")
damage_done = random.randint(0,5)
print ("You do ",damage_done,"damage")
monster_hp = monster_hp - damage_done
print ("the monster takes a hit, it has ", monster_hp,
"left")


elif answer == ("n"):
print ("you run away")

else:
print ("You and the monster just stare at one another")
else:
print ("You find nothing")
# if you decisde to not play it will kill you
elif des == ("no"):
hp = 0
print ("Maybe next time!")
else:
print ("please enter yes or no")

room()


this is the code i'm making. as the subject says im new to while statements. i 
am having problems with the monster battle part, it takes health away from the 
"monster" but as soon as it gets to 0 or less i'd like the code to start from 
the top and ask you to roll the die again. any help on this would be greatly 
appreciative
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: new to While statements

2013-08-06 Thread krismesenbrink
and it seems you are right about that, i don't know what was wrong with my IDE 
before, i closed it and opened it up again,seemed to fix the problem. thanks 
for taking the time to look at it anyway! 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: new to While statements

2013-08-06 Thread krismesenbrink
wow everyone thanks for the feed back! i'll have to rewrite this with 
everything you guys taught me. this makes ALOT more sense. :D
-- 
http://mail.python.org/mailman/listinfo/python-list


Issues with if and elif statements in 3.3

2013-08-08 Thread krismesenbrink
def town():
print ("You stand in the middle of Coffeington while you descide what"
" to do next, you have herd rumor of the Coffeington Caves that run"
"under the city, would you like to check them out?")
answer = input()
if answer == ("yes") or ("Yes") or ("y"):
print("You set out for the Coffeington Caves")
elif answer == ("no") or ("No") or ("n"):
print("Oh...well im sure you can find something else to do")
else:
print("You just stand  there")
town()



i don't know why the "elif" or "else" part of the "if statment" wont trigger. 
what ends up happening is that regardless of what answer you put in input it 
will always print out "you set out for the Coffeington Caves". whats supposed 
to happen is if you say "no" it should just end? i think anway.
-- 
http://mail.python.org/mailman/listinfo/python-list