Reputation: 927
I looked at similar questions but I didn't find this topic anywhere.
I want to know what does the tuple (1,)
mean in Python?
Upvotes: 1
Views: 1315
Reputation: 12097
From https://wiki.python.org/moin/TupleSyntax
One Element Tuples
One-element tuples look like:
1,
The essential element here is the trailing comma. As for any expression, parentheses are optional, so you may also write one-element tuples like
(1,)
but it is the comma, not the parentheses, that define the tuple.
Upvotes: 8