How to use unpacking operator (“*”) together with C-style string formatting?

Solution for How to use unpacking operator (“*”) together with C-style string formatting?
is Given Below:

I have recently begun the long, arduous (yet fulfilling) journey of becoming a programmer and am currently trying to get a foothold on the basics of string formatting in the latest version of Python.

In reviewing the 3 main methods of string formatting, I am having trouble combining the use of the unpacking operator (*) with string formatting using the % string formatting operator.

I do not have this problem when using string dot formatting:

>>> L = ["Bob", "Frank", "Joe"] 
>>> names = "Looking for {}, {}, {}"
>>> print(names.format(*L))
Looking for Bob, Frank, Joe

However, using % string formatting, I get error messages:

>>> Names = "Looking for %s, %s, %s"%*L
SyntaxError: invalid syntax
>>> Names = "Looking for %s, %s, %s"%(*L)
SyntaxError: can't use starred expression here

Is there any way to combine the unpacking operator with % string formatting, or is this something that can only be used in the context of string dot formatting?

Sebastian

% takes a tuple, so you can write

names = "Looking for %s, %s, %s" % tuple(L)

If format requires a single argument, values may be a single non-tuple object. Otherwise, values must be a tuple with exactly the number of items specified by the format string, or a single mapping object (for example, a dictionary).

https://docs.python.org/3/library/stdtypes.html#old-string-formatting

If you still want to use unpacking *, you can do

names = "Looking for %s, %s, %s" % (*L,)

although this is just a convoluted way of writing tuple(L) in this case; see PEP 448. Note that , cannot be omitted.