String Formatting

msgStr = "LocoRobo has {}"

msgStr = msgStr.format("robots")

print(msgStr)

msgStr = "Sensor readings of {}, {}, and {} meters."

print(msgStr.format(10, 11, 11))

In order to make string you must have curly brackets telling what each step you must input.

print('{:08.3f}'.format(231.2949))


0231.295

If we tried this line without the f, we get an entirely differently formatted result:

print('{:8.3}'.format(231.2949))


2.31e+02

This form is in scientific notation, which the format method chose as default with no f character present.