Syntax

Python F-String Formatting Syntax

In Python, f-string formatting: inserts values into a string — f"Total: {total:.2f}"

Quick Answer

Syntax
f"Total: {total:.2f}"
PythonSyntax

F-String Formatting

Code example
f"Total: {total:.2f}"

Inserts values into a string.

Learn More

How to f-string formatting in Python

  1. Open your Python file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Python F-String Formatting Syntax

Use f"Total: {total:.2f}".

Related Syntax References

Frequently asked questions

What is the Python syntax for f-string formatting?

Use this pattern: f"Total: {total:.2f}"

Can I copy this Python code example?

Yes. Use Copy code and adapt the example to your program.

Is this Python syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify