I’d like to use the match/case statement but currently PyCharm does not like it and when I try to run this code:
def test(action):
match action:
case "send":
pass
case "create":
pass
case "dump":
pass
it tells me
match action:
^
SyntaxError: invalid syntax
I use python 3.9.1 and PyCharm 2021.2.3 Pro. The keywords match and case are blue so I guess PyCharm recognizes them but is not able to run it. What am I missing here?
>Solution :
You are using Python version less than 3.10.
PEP 634: Structural Pattern Matching is introduced in python 3.10. See What’s New In Python 3.10
for more information.