What is the use of *
in .format(*)
?
When using it in the format function below print(new_string.format(*sum_string))
it changes the value of sum_string in the output from 18 to 1
Why does that happen?
I have read the following link about *args
and **kwargs
but couldn't understand how does that apply to the .format()
function
What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
sum_string = "18"
new_string = "This is a new string of value {}"
print(new_string.format(sum_string)) #it provides an output of value 18
print(new_string.format(*sum_string)) #it provides an output of value 1