EKons
EKons

Reputation: 927

What does (1,) mean in Python?

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

Answers (1)

Xiongbing Jin
Xiongbing Jin

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

Related Questions