All the docs and error messages seem to indicate that you need a tuple as the object in “”.join but it seems an anonymous list works as well – and format works inside the process also.
str1="The value of pi, " pi = 3.14159265359 str2=", can be estimated to 5 decimal places as " str3="." str4="".join(list(str1 + str(pi) + str2 + str(format(pi, ".5f")) + str3)) print(str4)
Results in:
The value of pi, 3.14159265359, can be estimated to 5 decimal places as 3.14159.
(Yes, I am aware that pi is irrational so no need to “call in” this one. And yes it can all be done much neater with an f string:
print(f"{str1}{str(pi)}{str2}{pi: <.5f}{'.'}")
)