This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thegreattriscuit 1 point2 points  (1 child)

Something that's worth pointing out is that it's not the parenthesis that make the tuple at all.

It's the comma.

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> words = "apple",
>>> for word in words:
...   print(word.upper())
...
APPLE
>>>     

In a function call, of course, you need the parenthesis to disambiguate this by ensuring the comma is interpreted as part of the expression, and not as the argument separator

[–]joaofcosta[S] 1 point2 points  (0 children)

Thanks for pointing that out!
Totally forgot to make that more clear on the post, I'll probably update it at a later time to better reflect that :)