14. I Got 99 Problems, But a Switch Ain't One


#1

I don't can pass this level of course. Someone can help me?
Instruction:
Na linha 2, preencha a declaração if para verificar se (if) answer é maior que 5.
02. Na linha 4, preencha elif de modo que a função resulte em -1 se answer for menor que 5.

Code:
def greater_less_equal_5(answer):
if 3 > 5:
return 1
elif 3 > 5:
return -1
else:
return 0

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

tks


#2

IndentationError: expected an indented block

You should indent your code with four spaces.like

def greater_less_equal_5(answer):
    if expression:     # need 4 spaces before if

and Your if and elif code should look something like

if EXPRESSION:
    do something  
elif OTHER EXPRESSION:
    do something 
else:
    do something

now if 3 > 5: is always false.you should do like

if answer > 5:

and for elif

elif answer < 5:


#3

The three print statements at the bottom are about the variable "answer" which is used in the first statement. So use "answer" without the quote marks in the different test conditions because the inputs for answer are being tested by the 3 numbers input at the bottom ie 4, 5, and 3. So think in terms of what would be output if each of these numbers were input in the "answer variable.


#4

Great.....thank's for your help!!!


#12