I saw this code somewhere, which writes:
print("{:-^16}".format("TEXT"))
The output is:
------TEXT------
I understand what the {}
brackets do, but what does the -^16
mean? I tried searching online but couldn't find anything.
I saw this code somewhere, which writes:
print("{:-^16}".format("TEXT"))
The output is:
------TEXT------
I understand what the {}
brackets do, but what does the -^16
mean? I tried searching online but couldn't find anything.
Braces are used as placeholders for the formatted string.
16 is for the size of the string => 16 characters
^ center aligns the result (within the available space)
You can find more information here: https://www.w3schools.com/python/ref_string_format.asp