[Python] The tilde operator in Python

Discussão em 'Python' iniciado por Stack, Dezembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    What's the usage of the tilde operator in Python?

    One thing I can think about is do something in both sides of a string or list, such as check if a string is palindromic or not:

    def is_palindromic(s):
    return all(s == s[~i] for i in range(len(s) / 2))


    Any other good usage?

    Continue reading...

Compartilhe esta Página