Skip to content

invalid syntax error with something that looks like a match statement #22528

@KotlinIsland

Description

@KotlinIsland

Summary

from re import *

def main(x, y, z):
    match [x, y, z]:                        {   #<--- load bearing brace
        case [0, 1, 2]: print("a"),
        case [3, 4, 5]: print("b"),
        case [_, _, _]: exit(1)
                                            }   #<--- load bearing brace
    print("all good")

main(4, 2, 0)

playground

Expected newline, found { (invalid-syntax) [Ln 4, Col 45]

finders credit to @decorator-factory

Solution

from re import match

match[0]: int  # Expected newline, found name(invalid-syntax)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparserRelated to the parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions