I’m reading a book to read and it covers this below example.
somelist = list(SPAM)
parts = somelist[0], somelist[-1], somelist[1:3]
'first={0}, last={1}, middle={2}'.format(*parts)
Everything seems clear apart from the star being used at the end of the last line. The book fails to explain the usage of this and I hate to progress on without full understanding things.
Many thanks for your help.
It’s argument unpacking (kinda) operator.
is the same as
(for some callable
fun).There’s also star in function definition, which means “all other positional arguments”: