0

I understand from Python tutorial that to create a tuple containing a single value you have to include a comma, even though there is only one value: tup1 = (50,) What is the significance for putting comma at the end of the constructor?

Jagadesh
  • 41
  • 7
  • The comma defines the tuple, not the parenthesis. `tup1 = 50,` is a tuple. –  Jan 04 '16 at 09:49
  • 1
    Because `(50)` is just a grouped expression, not a tuple. The comma defines tuples, not parentheses, although in many contexts you need to use parentheses anyway to disambiguate the comma. – Martijn Pieters Jan 04 '16 at 09:58

0 Answers0