I have been attempting to parse variables from a list into a function separately. I don't know how to parse each value from the list into the .format()
function. The solution is probably pretty obvious but I can't seem to find it. Here is a simplified version of the code:
variables = ["a", "b", "c", "d"]
def format(variables):
string = "{:^4}" * len(variables)
#don't know how to do
return string.format(variables_from_list)
Ideally, the code would work the same as below:
variables = ["a", "b", "c", "d"]
def format(variables):
string = "{:^4}" * len(variables)
print(string.format("a", "b", "c", "d"))
Any help is appreciated!