[Python] Why do tuples need at least one comma?

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

  1. Stack

    Stack Membro Participativo

    If I want to create a tuple with only one value, I need to put a comma after it:

    (value,)


    While:

    (value)


    is the same as:

    value


    Why does Python have this syntax? Isn't it redundant? Why not just use () for tuples only?

    Continue reading...

Compartilhe esta Página