Conditionals & Control Flow


#1



https://www.codecademy.com/en/courses/python-beginner-BxUFN/3/4?curriculum_id=4f89dab3d788890003000096#

it says a lot is wrong


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


#2

def greater_less_equal_5(answer):
if 4>5:
return 1
elif : 1**2
return -1
else:
return 0

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


#3

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

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


#4

You'll want ot use the argument inside the function:

if answer > 5:
    return 1

and so on. There is no conditional for else, just a return value, 0.


#5

Thanks i´ll try that


#6

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

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

File "python", line 2
if 5<:
^
SyntaxError: invalid syntax


#7

def greater_less_equal_5(answer):
if answer 5<:
return 1

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


#8

As in the earlier example, the comparison operator goes between the operands:

a < b

a > b

You're that close to the solution, just change up the placement in your conditions.


#9

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