Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 1
    Is f"{" ".join(map(str, a))}" what you look for? Commented Nov 6, 2024 at 21:38
  • 1
    What exactly are you looking to achieve? If you want to print all the values of the tuple, just unpacking with *a and passing the values as individual arguments works just fine, as you demonstrated. You can unpack the tuple and use it any way you like, including passing it to some function that performs additional formatting - but what formatting were you looking to apply? (note that (<value>, ...) is the norrmal representation of a tuple, so it makes a lot of sense for an f-string to use that) Commented Nov 6, 2024 at 21:38
  • 4
    Note that print has nothing to do with the unpacking. You can always unpack a tuple with * and one of its uses is to unpack it into the parameters of a function like print() which is what you're doing here. Commented Nov 6, 2024 at 21:43
  • 2
    NB: print doesn't remove commas and brackets. Those are just characters that would be generated when you would convert a tuple to string. But when you pass it *a, print doesn't see the tuple, but gets its members as separate arguments. There are no commas or brackets involved. Commented Nov 6, 2024 at 21:45
  • 1
    See also: stackoverflow.com/q/41896356/967621 Commented Nov 6, 2024 at 22:25