[Python] Check if substring is in tuple of strings

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    Which is the most elegant way to check if there is an occurrence of several substrings in a tuple of strings?

    string_tuple = ('first-answer', 'second-answer', 'third-answer')
    substr1 = 'first'
    substr2 = 'second'
    substr3 = 'third'

    # PSEUDOCODE:
    # if substr1 in string_tuple and \
    # substr2 in string_tuple and \
    # substr3 in string_tuple:
    # SHOULD return True

    Continue reading...

Compartilhe esta Página