I don't understand why my conditional is wrong?

Hi there,
I have a problem with the following code:

# Write your in_range function here:
def in_range(num,lower,upper):
	return True if num >= lower and num <= upper
	else return False

the error output is as follows:

  File "script.py", line 3
    return True if num >= lower and num <= upper
                                               ^
SyntaxError: invalid syntax

The SyntaxError doesn`t help much, the error is in line 3 alright. But I have no Idea what went wrong.

Is this supposed to be Python? That is not how conditional statements are structured.

if condition:
    # do something
else:
    # do something else
1 Like