[Python] Why does Python use different syntax for split() and join()? [duplicate]

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

  1. Stack

    Stack Membro Participativo

    In Python, when we use split(), the syntax looks like this:

    list_result = string.split(separator)



    But when we use join(), it's written like this:

    string_result = separator.join(list_of_strings)



    Why is the format different? Why don't we write join() like this instead?

    list_of_strings.join(separator)



    Is it just a design choice made by Python's creators, or is there a deeper reason why join() can’t follow the same pattern as split()?

    Continue reading...

Compartilhe esta Página