Pattern matching is a programming language feature that allows you to compare a value or data structure against a set…