Grammar error in I got 99 problems, but a switch ain't one

#1

if 8 > 9:
print "I don't get printed!"
elif 8 < 9:
print "I get printed!"
else:
print "I also don't get printed!"

In the example above, the elif statement is only checked if the original if statement if False

The last "If" after statement and before False... Shouldn't it be a "is" not a "if"

#2

I am stuck in this code as well

#3

I don't understand what you mean by that....as for:

That's what if elif statements are suppose to do. First the if statement is checked, if the input does not fit the criteria of the "if" statement, then it moves on the "elif" statement, after that comes the else, which is for everything that does not fit either of those criterias.

#4

#5

if 7 > 8 :
return 6
elif 7 < 8:
return 4
else:
return -1

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

i have no idea what i m doing... actually i dont get whats function output -1

hope you can help me

#6

return 1
return -1
else:
return 0

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

here

#7

Thank you very much for that... I wracked my brain for close to 2 whole shifts of work (16hrs) trying to code this.. I was putting in actual numbers for the expressions, I didn't realize it actually wanted "answer" instead. I should have looked at this forum 15 hrs ago. I was coding it like I was supposed to create an expression that was greater than or less than five (see below):

if 3 + 1 > 5:
return 1
elif 3 + 1 < 5:
return -1
else:
return 0

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)
====

#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.