+ 7
vals=[2,4,7] new="{1}{2}{1}".format(vals[0],vals[2],vals[1]) print(new)
Needs reason of output
6 Answers
+ 8
new="{1}{2}{1}".format(2,7,4)
Inside the Curly brackets we write the index no. Whose value we want,so we will get
new="747"
+ 7
đđđ€Łđ€Łđ€Łno man your answer is best
+ 7
Why not using an f-string? It is much more clear and concise, and can do more than other formatting methods.
print(f'{vals[2]}{vals[1]}{vals[2]}')
You don't need placeholders and a format(), it can be done just how it's shown here. If it is used without print, it can generate a string, that looks like the output.
+ 4
https://www.sololearn.com/Discuss/2229853/?ref=app
Check it out...
+ 1
đ
đ
+ 1
In curly brackets index is given so at index 1in vals is 7 and index 2 is 4 and finaly index 1 is 7 so output of code or new="747"