How do i do this


#1

def greater_less_equal_5(answer):
if answer != 5 :
return 1
elif answer == 5:
return -1
else:
return 0

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


#2

you are pretty close, but != and == are not the right comparison operators

we need to check if answer is greater then 5, else if check answer is smaller then 5


#3

so what do I do to make it right


#4

use the right comparison operators, what are the comparison operator for greater then? What is the comparison operator for smaller then?


#5

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

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


#6

ive completed it now thanks


#7

the exercise approves this? >= means greater then or equal to, please use greater then (>) operator

so then the function doesn't return the right value when answer=5


#8

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