Does this code work?

Anyone know why this doesn’t work? It returned True and False correctly with the prompts but was not accepted as correct.

def in_range(num, lower, upper):
__return num >= lower and num <= upper (underscores used to show indent-not in actual code)

1 Like

It works fine!!

Two notes:

  1. You can reproduce code properly by using the </> icon found in the menu bar in the text box where you type

  2. Python understands a construction like: lower <= num <= upper, which I find easier to read than the use of and with two comparisons. For one thing, if the carats are pointed left, it creates an analogy to the number line that is illuminating.