- 1
What is the result of this code? print ({0}{1}{3}". format ("abra", "acad"))
3 Answers
+ 9
Marvinrexa ,
as Jan Markus already mentioned, there is a double quote missing just before the first curly braces.
but there is also an other issue, because you are using 3 placeholders but only 2 arguments in the format() function. if you like to share your intent with this code, we may help you.
+ 4
print("{0}{1}{3}".format(a,b,c,d))
==> abd
+ 3
I believe the code is supposed to be
print("{0}{1}{0}".format("abra", "cad"))
In this case the output is
"abracadabra"
The curly braces with numbers are placeholders which are replaced by the string with the respective index. In this case it is the string at index 0, followed by the string at index 1, followed by a second use of the string at index 0.