0

I found such syntax:

dota_teams = ["Liquid", "Virtus.pro", "PSG.LGD", "Team Secret"]
data = [[1, 2, 1, 'x'],
['x', 1, 1, 'x'],
[1, 'x', 0, 1],
[2, 0, 2, 1]]
format_row = "{:>12}" * (len(dota_teams) + 1)
print(format_row.format("", *dota_teams))
for team, row in zip(dota_teams, data):
    print(format_row.format(team, *row))

I don't understand fully what "*" does here. (In .format() argument before "dota_teams" or "row") .

What is it responsible for in this syntax?

  • @MikeScotty That doesn't look like it fits this question at all. This question has the code `"{:>12}" * (len(dota_teams) + 1)` wheras your suggested duplicate has code like `*args`. – Stephen Ostermiller Dec 21 '22 at 15:53
  • @StephenOstermiller true, when you look only at the question, but please scroll to the [second answer](https://stackoverflow.com/a/36926/4349415) | EDIT: seems I misunderstood you, because you may have OP's question wrong. OP is asking about ``*`` before ``dota_teams`` and ``row``, not the string multiplication – Mike Scotty Dec 21 '22 at 15:54
  • @StephenOstermiller the question and answer supply information regarding both keyword arguments (`**`) and args (`*`). – Xiddoc Dec 21 '22 at 15:55
  • 1
    @StephenOstermiller You're looking at the one asterisk they're **not** asking about. – Kelly Bundy Dec 21 '22 at 15:56
  • To be fair, the line I picked out also has `dota_teams` after the asterisk (but not directly after.) Darn not-minimal example code. – Stephen Ostermiller Dec 21 '22 at 16:02

0 Answers0