[Python] Is there a way to use endswith/startswith in match case statements? [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 19, 2025.

  1. Stack

    Stack Membro Participativo

    Is there a way to use match case to select string endings/beginnings like below?

    match text_string:
    case 'bla-bla':
    return 'bla'
    case .endswith('endofstring'):
    return 'ends'
    case .startswith('somestart'):
    return 'start'

    Continue reading...

Compartilhe esta Página