If you start to create a new python3 question and click Customise you'll get to see the template for the default python3 question type. It includes the line
__student_answer__ = """{{ STUDENT_ANSWER | e('py') }}"""
which gives you a variable containing the student's submitted code. If you call splitlines() on that, you'll get all their code lines. So you can check the line(s) preceding your target line to see if it's a comment and perhaps if it contains various key words you might expect. But there's no easy way to check if it actually makes sense. You need an LLM for that!