[Python] Python conditional list joins

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list that looks like this:

    [
    'A',
    'must',
    'see',
    'is',
    'the',
    'Willaurie',
    ',',
    'which',
    'sank',
    'after',
    'genoegfuuu',
    'damaged',
    'in',
    'a',
    'storm',
    'in',
    '1989',
    '.'
    ]


    As you can see, there is punctuation. I want to call .join using a blank space except for the cases where the string is punctuation, then I don't want a separator.

    What's the best way to do this?
    I've been trying for a while and my solutions are getting way too complicated for what seems like a simple task.

    Thanks

    Continue reading...

Compartilhe esta Página