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