I\'m new here, and to python also.. The if statments in the following code are not running. does anyone know why? This is a camel game I need to submit by sunday.
I am going to assume that these are the if statements that you speak of:
if thirst > 4 and thirst <= 6:
print "You are thirsty."
print ""
elif thirst > 6:
print "You died of thirst!"
done = True
if tiredness > 5 and tiredness <= 8 and done != True:
print "Your camel is getting tired."
print ""
elif tiredness > 8 and done == False:
print "Your camel is dead."
done = True
if distance <= 0 and done != True:
print "The natives caught you."
done = True
elif distance < 15 and done != True:
print "The natives are getting close!"
if summ >= 200 and done == False:
print "You won!"
done = True
if random.randint(1, 100) <= 5 and done != True:
print "You found an oasis!"
print ""
thirst = 0
tiredness = 0
drinks = 3
Your if statements are running, but they are only running at the beginning of the code because they are not in a function or a loop, they are only being run at the very start of your code.
if you are using if statements or any loops and such, you need to indent what is inside them using the tab key. if you want to have something inside an if statement and a loop or something of that sort, you do tab twice. These are to tell python where your loops and comparisons end. If you do not indent at all, python will think that there is nothing inside the loop. You also need to indent with functions, if you want to put the if statements inside of the loop you need to indent it likewise.
Here is and example:
while something1 == something2:
if anotherthing1 == anotherthing2:
print "something happened"
somethinghappened = True
That is just an example, implement it the way you need to.
put it in a loop and indent the if statements correctly