Conditionals & Control Flow 14 Please Help


#1

Task: On line 2, fill in the if statement to check if answer is greater than 5.
On line 4, fill in the elif so that the function outputs -1 if answer is less than 5.

Answer:
def greater_less_equal_5(answer):
if 3 > 4:
return 1
elif -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)

What is wrong with it?


#2

You're supposed to be comparing the "answer" input, not 3 and 4, nor -1 and 5.

Answer:


def greater_less_equal_5(answer):
if answer > 5:
return 1
elif answer < 5:
return -1
else:
return 0
```

#3

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