I do not understand what the '*' does in my code. What does it do and what is it called?
numbers = [x for x in range(5)]
mystrings = "numbers:{0}, {1}, {2}, {3}".format(*numbers)
print(mystrings)
I do not even know what it is called (or I would have searched online already). I was learning how to use String.format() and wanted to add items from a list without typing them all out manually. I found this solution but it came with no explanation.
This is what I was trying to avoid:
mystrings = "numbers:{0},{1},{2},{3}".format(numbers[0],
numbers[1],
numbers[2],
numbers[3]
)