Practice mode Python

In a Python match statement, which pattern acts as a wildcard that matches any value?

Correct answer D. case _:

Explanation

The underscore pattern _ always succeeds and binds no name, so case _: is used as the final catch-all branch. Python has no default keyword; writing case default: would capture the subject into a variable named default, and case else: is a syntax error.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.