Quick question

Hi,

Can you please help: the last two “returns” confuse me.
I guessed that the 3rd return would be separated from the 2nd by an “else” statement. However it lists them “return” and then the next line another “return”.

This is the solution that was given to me. Can you please help me understand?

Thank you very much,
Josh

The else is optional in python (but really helps readability). I recommend using them in your code while you’re getting used to the language, but you’re totally free not to :slight_smile:

Some languages (like haskell) require them.

1 Like

You’re the best. Thank you very much Toastedpitabread!

No worries!

Just to be clear, it’s often better to be explicit with else because sometimes there will be code you won’t want to run under that.

In this is example it works because a return automatically ends the function once it is reached.