How to Print a Variable and Its Value Using Python f-Strings

How to Print a Variable and Its Value Using Python f-Strings

Python Tip: Append the variable with = to also show the variable name when using Python f-string's.

Heres an example 👇

x, y, z = 1, 2, 3

f"{x} {y} {z}"
# Output:
# '1 2 3'

f"{x=} {y=} {z=}"
# Output:
# 'x=1 y=2 z=3'

Subscribe to our newsletter to keep updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox.
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!