-2

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?

LinFelix
  • 1,026
  • 1
  • 13
  • 23
t3chb0t
  • 16,340
  • 13
  • 78
  • 118

1 Answers1

3

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.

Abdul Niyas P M
  • 18,035
  • 2
  • 25
  • 46