[Python] Python list joining — include separator at the start or at the end

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

  1. Stack

    Stack Membro Participativo

    The output for ', '.join(['a', 'b', 'c', 'd']) is:

    a, b, c, d


    Is there a standard way in Python to achieve the following outputs instead?

    # option 1, separator is also at the start
    , a, b, c, d

    # option 2, separator is also at the end
    a, b, c, d,

    # option 3, separator is both at the start and the end
    , a, b, c, d,

    Continue reading...

Compartilhe esta Página