Help


#1

Instructions:
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.

Here is my answer. What am I doing wrong?

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

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


#2

Do not copy the example in the lesson text (ignore it) and instead follow the instructions. What are you supposed to do with answer?


#3

ok, i answered the elif 5 > 3:

return -1
it did not work and stated
It looks like your function output 1 instead of -1 when answer is 3. Make sure you filled in the if and elif statements correctly!


#4

The name of the function should be an indication of what the function is supposed to check. Is answer greater than, less than or equal to 5?


#5

can you give me an example . I ordered a book you suggested which i believe it will help with me understanding better


#6

i cannot figure out was is less than 5. i tried a lot of different numbers. i know once i figure it out, it was so simple. do you have any other suggestions


#7

The values are in the call expressions as arguments, 4, 5, and 6. In the function those values are represented by the parameter, answer. That is what to compare to 5.

if answer > 5:
    # 1
elif answer < 5:
    # -1
else:
    # 0

#8

i figured it out. it was very simple as it gave me the code ,and i had to input it. Now, i am on to the final code for all of it. Thanks so much for your suppport and help


#9

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