? confused


#1

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

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

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: invalid syntax (python, line 2)

File "python", line 2
if answer is < 5 (answer):
^
SyntaxError: invalid syntax


#2

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

Delete is from if-elif conditions!
Then it will work..
for example..
instead of this..
if answer is < 5 (answer)
write
if answer < 5 (answer)

Operators like:

> <,>,<=,>=,==,!= are called comparator operators and checks if values are greater >than/less than,greater than equal to,less than equal to, equal to or not equal to.
(They check if values are equal or not)

...

but is operator works in different way..
is operator checks if two values points to same object or not!


#3

now I'm getting

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: 'int' object is not callable

Traceback (most recent call last):
File "python", line 9, in
File "python", line 2, in greater_less_equal_5
TypeError: 'int' object is not callable

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

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


#4

Delete them...


#5

Thank you very much.


#6

Did it solved the problem / error?


#7

yes that last thing from you helped very much


#8

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