7 Comments
User's avatar
⭠ Return to thread
Ash Roberts's avatar

I'm a little confused about the unpacking operator. Not how to use it, because you made that fairly clear, but that it is necessary. All this time, I've been printing lists directly. It appears to ignore the sep argument, but Python will print a list or any other iterable directly

Expand full comment
Stephen Gruppetta's avatar

That's a great point. Yes, you can print the list directly but this will print it out in the form of a Python list, with the square brackets and quotation marks and commas and all that. If you're fine with that, that's great, but sometimes you want to display the items in some other form, without all the clutter of the list syntax (especially if it's an output for a non-Python audience). Unpacking allows you to do so…

And as you say, the `sep` parameter won't work if you print the list directly since you only have one object as argument for `print()` in this case, so there's nothing to separate

Expand full comment