To print a variable in Python, pass it to print(). To print it with text, use an f-string: print(f"Total: {total}"). A comma works too, but it adds a space between items:
total = 59.97
print(total)
print(f"Total: ${total}")
print("Total:", total)
The rest of this guide covers numbers, dollars, several variables at once, a variable’s name and value, and capturing output. Every example ran on Python 3.14.7, and the outputs are real.

Print a variable in Python with print()
print() takes any value and writes its text form to the screen. Here it is with the common types:
city = "Denver"
price = 19.99
qty = 3
in_stock = True
tags = ["sale", "new"]
item = {"sku": "A-102", "price": 19.99}
print(city)
print(price)
print(qty)
print(in_stock)
print(tags)
print(item)
print(repr(city))
Output:
Denver
19.99
3
True
['sale', 'new']
{'sku': 'A-102', 'price': 19.99}
'Denver'
Strings print without quotes, and lists and dictionaries print the way you’d type them. True prints as a word, and numbers print as they are.
repr(city) added the quotes back. That’s also what you see when you type a variable’s name alone in the interactive shell, which is why the shell shows 'Denver' while print() shows Denver.
New to variables themselves? Python variables explained covers naming and types before you print them.
Print a string and variable together
This is the question most people are really asking. There are three everyday ways, and they don’t behave the same:
item = "coffee"
price = 19.99
qty = 3
print("Item:", item, "Qty:", qty)
print("Price: $", price)
print("Price: $", price, sep="")
print(f"Price: ${price}")
print("Qty: " + str(qty))
try:
print("Qty: " + qty)
except TypeError as err:
print("TypeError:", err)
Output:
Item: coffee Qty: 3
Price: $ 19.99
Price: $19.99
Price: $19.99
Qty: 3
TypeError: can only concatenate str (not "int") to str

A comma prints each item with a space between them. That’s fine for Item: coffee, but it put a gap after the dollar sign in Price: $ 19.99.
sep="" removes those spaces, and the f-string version needs no fix at all. I reach for an f-string whenever the spacing matters.
The + operator only joins a string to a string. "Qty: " + qty raised TypeError because qty is an integer, so wrap it in str() or use an f-string.
Printing strings and integers together goes deeper into that error. To build a string for later instead of printing it, see inserting a variable into a string.
Format variables inside an f-string
An f-string does more than drop a variable into text. A format spec after a colon controls decimals, commas, percentages and dates:
from datetime import date
price = 1234567.891
rate = 0.4567
qty = 3
shipped = date(2026, 9, 30)
print(f"Price: ${price:,.2f}")
print(f"Rounded: {price:.0f}")
print(f"Rate: {rate:.1%}")
print(f"Padded: {qty:03d}")
print(f"Shipped: {shipped:%B %d, %Y}")
print(f"Total: ${price * qty:,.2f}")
print(f"Braces: {{qty}} = {qty}")
Output:
Price: $1,234,567.89
Rounded: 1234568
Rate: 45.7%
Padded: 003
Shipped: September 30, 2026
Total: $3,703,703.67
Braces: {qty} = 3

:,.2f gives two decimals with thousands separators, which is what you want for US dollar amounts. :.1% multiplies by 100 and adds the percent sign.
Dates accept the same codes as strftime(), so :%B %d, %Y printed September 30, 2026. The expression price * qty ran inside the braces, and doubled braces printed literal ones.
For more on number formats, see printing 2 decimal places in Python and formatting numbers with commas.
Quotes inside an f-string
Printing a dictionary value inside an f-string means quotes inside quotes:
order = {"city": "Austin", "state": "TX"}
print(f"Ship to {order['city']}, {order['state']}")
print(f"Ship to {order["city"]}, {order["state"]}")
Output:
Ship to Austin, TX
Ship to Austin, TX
Both lines work on Python 3.12 and later. On 3.11 and older, reusing the outer double quotes inside the braces is a SyntaxError, which I confirmed on Python 3.8. Single quotes inside work on every version.
Print multiple variables on one line
Pass several variables to one print() call, and control what goes between and after them with sep and end:
first, last, age = "Ava", "Johnson", 34
print(first, last, age)
print(first, last, age, sep=", ")
print(first, last, sep="_", end="!\n")
print("Loading", end="")
print("...", end=" ")
print("done")
states = ["TX", "CA", "NY"]
print(states)
print(*states)
print(*states, sep=" | ")
Output:
Ava Johnson 34
Ava, Johnson, 34
Ava_Johnson!
Loading... done
['TX', 'CA', 'NY']
TX CA NY
TX | CA | NY
sep replaces the space between items, and end replaces the newline at the end. With end="", the next print() continues on the same line, which is how the loading message came out on one line.
A list prints with brackets and quotes. The * in print(*states) unpacks it, so each item prints as a separate argument and sep applies to them.
There’s more on this in printing on the same line in Python and printing a new line after a variable.
Print a variable’s name and value
For debugging, Python 3.8 added a shortcut: put = after the variable in an f-string and it prints the name too.
price = 19.99
qty = 3
city = "Denver"
print(f"{price=}")
print(f"{price = }")
print(f"{price=:.1f}")
print(f"{city=}")
print(f"{city=!s}")
print(f"{price * qty=:.2f}")
Output:
price=19.99
price = 19.99
price=20.0
city='Denver'
city=Denver
price * qty=59.97

= in an f-string prints the expression, then its value.Spaces around the = are kept in the output, and a format spec still works after it. It also works on whole expressions, as price * qty shows.
Notice the quotes in city='Denver'. The = form uses repr() by default, and !s switches it back to the plain text you’d get from print(city).
Print the type of a variable
When a value doesn’t print the way you expect, check its type. type() gives the class, and .__name__ gives just the name:
values = [42, 19.99, "42", True, None, [1, 2]]
for v in values:
print(f"{v!r:<8} {str(type(v)):<18} {type(v).__name__}")
Output:
42 <class 'int'> int
19.99 <class 'float'> float
'42' <class 'str'> str
True <class 'bool'> bool
None <class 'NoneType'> NoneType
[1, 2] <class 'list'> list
42 and '42' look almost the same when printed, but one is an int and one is a str. That’s often the cause of a TypeError when you combine them.
type(v).__name__ drops the <class ...> wrapper. In an if statement, test with isinstance(v, int) instead of comparing types.
Print to a variable: capture print output
print() writes to the screen and returns None, so result = print(...) doesn’t save anything. To keep the text, capture it:
import io
from contextlib import redirect_stdout
result = print("Hello")
print("print() returned:", result)
buffer = io.StringIO()
with redirect_stdout(buffer):
print("Order", 1042, "shipped")
print("Total: $59.97")
captured = buffer.getvalue()
print("captured:", repr(captured))
log = io.StringIO()
print("Refund", 1043, file=log)
print("log:", repr(log.getvalue()))
Output:
Hello
print() returned: None
captured: 'Order 1042 shipped\nTotal: $59.97\n'
log: 'Refund 1043\n'
