I want to do something like String.Format(\"[{0}, {1}, {2}]\", 1, 2, 3)
which returns:
[1, 2, 3]
How do I do this in Python?>
Before answering this question please go through couple of articles given below:
Python Official Docs here
Useful article:
Now let's answer this question
Question: I want to do something like:
String.Format("[{0}, {1}, {2}]", 1, 2, 3)
which returns:
[1, 2, 3]
How do I do this in Python?
Answer:
Well this is certainly a one-line code answer which is
print("[{0},{1},{2}]".format(1, 2, 3))
When you execute this one-line code a list containing three values as [1, 2, 3]
will be printed. I hope this was pretty simple and self-explanatory.
Thanks
Tanu