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


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

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

Oops, try again. 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!

What is the problem?


you want to see if answer (the function parameter) is greater, smaller or equals 5. use answer correctly in the if/elif condition


How can I do that :-Q



you can put the variable in the comparisson:

if answer < 5:
    print("answer is smaller than 5")


Can you please elaborate? No matter what I do, it keeps print 1 instead of -1


Can you show us your code?


I was thinking about it too literally.
I was keying in if 5>1

when the answer was already set to be defined


answer is a variable, so you can just compare it with 5:

answer > 5


How is print towards the end of the program helping set the variable to 4 or 5 or 6; I am totally missing this !

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

Thanks in advance,


you call the function here:

print greater_less_equal_5(4)

you pass an argument (4) into the function, so the function parameter will now hold the value passed by the function call


Thanks a bunch, somewhat clear. Guess will take some more practice to grasp the details.



def example(parameter):
   print parameter
example("see how the parameter is a place holder for the value past into the function call")

hopes that helps


Yes thank you, this helps.


Thanks for your comment. Helped me figure it out.


it says I have to have a number.


if you have a question, make a new topic, don't clutter a topic, topics are actually only to help the person who original created the topic


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