Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Match statement
#1
I' m tryng to use the match statement to manage different event.type but givi me this error:

Output:
File "Main.py", line 34 match event.key(): ^ SyntaxError: invalid syntax
the code is :

for event in pygame.event.get():

        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        elif event.type == pygame.KEYDOWN:

            match event.key():

                case pygame.K_DOWN:
                    print("giu")

                case pygame.K_UP:
                    print("su")

                case pygame.K_LEFT:
                    print("sinistra")

                case pygame.K_RIGHT:
                    print("destra")
what am I doing wrong?
Reply


Messages In This Thread
Match statement - by Fabrizio_fg - May-27-2023, 09:20 AM
RE: Match statement - by deanhystad - May-27-2023, 10:35 AM
RE: Match statement - by Fabrizio_fg - May-27-2023, 10:53 AM
RE: Match statement - by deanhystad - May-27-2023, 11:02 AM
RE: Match statement - by Fabrizio_fg - May-27-2023, 11:17 AM
RE: Match statement - by buran - May-27-2023, 01:29 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020