How do you define predict() function from the code below?

Your indentation does not match on the “else” clause there. Indentation is a key part of the syntax in python: you can’t just align things to please your own eyes. You have to follow the rules.

You can’t just ignore the error message. It clearly tells you that the indentation is wrong. And that then causes the function not to be defined, since it can’t be compiled because it has a syntax error.

Thank you so much.