0

this is an elementary question but I couldn't find any explanation on google.

print([])

prints

[]

but

print(([]))

also prints,

[]

but then why use this form if it is the same as using normal list notation? I thought this was strange because I thought "()" is a tuple.

  • 2
    `([],)` (or just `[],`) would be a tuple containing a list - the _comma_ is what matters. There's _no_ difference between `[]` and `([])` in what you've posted. _"why use this form"_ - we don't know why you used that form. – jonrsharpe Jun 22 '22 at 14:54
  • @jonrsharpe that might be one of the most confusing aspects of Python. It goes out of its way to make you think the parentheses are the defining characteristic of a tuple, but it turns out to be the comma in the end. – Mark Ransom Jun 22 '22 at 15:06

0 Answers0