While mentoring a new Python developer, I realized that one of the most common beginner questions is, “How do I print variables in Python?”
Even though this sounds simple, there are actually several ways to print variables in Python efficiently and professionally. I’ve used different techniques depending on the project, from quick debugging to formatting complex outputs for reports.
In this tutorial, I’ll show you multiple ways to print variables in Python. We’ll start with the basic print() function and then move on to more powerful methods like f-strings, format(), and string concatenation.
Method 1 – Print Variable Using the print() Function
The simplest and most common way to print a variable in Python is by using the built-in print() function.
This method is perfect for beginners and works for all data types, strings, integers, floats, and even lists or dictionaries.
name = "John"
age = 30
city = "New York"
print("Name:", name)
print("Age:", age)
print("City:", city)You can refer to the screenshot below to see the output.

In this example, I simply passed multiple arguments to the print() function separated by commas. Python automatically adds a space between each argument.
Method 2 – Print Variable Using String Concatenation
Another way to print variables in Python is by concatenating strings using the + operator. This method works well when you want to join variables with text, but keep in mind that all variables must be converted to strings first using the str() function.
name = "Alice"
state = "California"
income = 85000
print("My name is " + name + ". I live in " + state + " and earn $" + str(income) + " per year.")You can refer to the screenshot below to see the output.

Here, I used the + operator to join strings and variables. It’s simple, but not the most efficient for large-scale programs. If you accidentally forget to convert a number to a string, Python will raise a TypeError. So, use this method carefully.
Method 3 – Print Variable Using f-Strings (Recommended)
Starting from Python 3.6, f-strings became my go-to method for printing variables. They are fast, readable, and allow you to embed variables directly inside string literals using curly braces {}.
employee = "Michael"
department = "Finance"
salary = 95000
print(f"Employee {employee} works in the {department} department and earns ${salary:,} annually.")You can refer to the screenshot below to see the output.

This method is clean and efficient. Notice how I used {salary:,} to format the number with commas, a small touch that makes the output more readable, especially for U.S. currency values. F-strings also allow you to perform inline calculations or call functions within the braces.
hours_worked = 40
hourly_rate = 25
print(f"Total weekly pay: ${hours_worked * hourly_rate}")This approach is not only elegant but also improves code readability, which is crucial in professional Python development.
Method 4 – Print Variable Using the format() Method
Before f-strings, the .format() method was the standard way to print variables in Python. It’s still widely used, especially in projects that need to maintain compatibility with older Python versions (below 3.6).
product = "Laptop"
price = 1299.99
quantity = 3
print("The total cost for {} units of {} is ${:.2f}".format(quantity, product, price * quantity))In this example, {} acts as placeholders for variables. You can also use positional or keyword arguments for more control.
print("Hello, {name}! Welcome to {city}.".format(name="Sarah", city="Chicago"))The .format() method is flexible and works well when you want to reuse templates or build formatted strings dynamically.
Method 5 – Print Multiple Variables in One Line
Sometimes you may want to print multiple variables on the same line. Python’s print() function automatically adds a newline after each call, but you can override that using the end parameter.
for i in range(1, 6):
print(i, end=" ")This will print:
1 2 3 4 5You can refer to the screenshot below to see the output.

By setting end=” “, I replaced the default newline with a space. You can also use commas, dashes, or any other character as a separator.
Method 6 – Print Variables for Debugging (Using repr())
When debugging, I often use the repr() function to get the official string representation of a variable. It’s especially useful when you want to see hidden characters like \n (newline) or \t (tab).
text = "Hello\nWorld"
print("Without repr():", text)
print("With repr():", repr(text))This method helps identify formatting issues or unexpected whitespace in your Python strings. It’s a small trick that can save hours of debugging time.
Method 7 – Print Variables Using Formatted String Templates
For more advanced use cases, Python’s string module provides a Template class that allows placeholder substitution.
This is useful when you’re working with user-defined templates or configuration files.
from string import Template
template = Template("Dear $name, your order total is $$${amount}.")
message = template.substitute(name="David", amount=120.50)
print(message)This prints:
Dear David, your order total is $120.5.The Template class is safer than f-strings when dealing with user input, as it avoids code injection risks.
Bonus Tip – Print Variables to a File
Sometimes, instead of printing to the console, you may want to print variables to a file, for logging or record-keeping. You can easily do this by specifying the file parameter in the print() function.
name = "Sophia"
score = 98
with open("student_report.txt", "w") as f:
print(f"Student: {name}, Score: {score}", file=f)This will create a file named student_report.txt and write the formatted text inside. It’s a neat way to log Python output for later analysis.
Common Mistakes When Printing Variables in Python
Over the years, I’ve seen beginners make a few common mistakes when printing variables in Python.
Here are some quick pointers to avoid them:
- Forgetting to convert numbers to strings when using concatenation (+ operator).
- Using commas incorrectly — remember, commas automatically add spaces.
- Mixing f-strings with quotes incorrectly, e.g., forgetting the
fbefore the string. - Printing large data structures directly, which can clutter your output — use
pprintfor better formatting.
Practical Example – Display a Sales Report
Let’s combine everything we’ve learned into a small real-world example. This example prints a formatted sales report for a U.S.-based retail store.
store_name = "TechMart USA"
salesperson = "Emma"
total_sales = 157890.75
region = "California"
print(f"--- {store_name} Monthly Sales Report ---")
print(f"Salesperson: {salesperson}")
print(f"Region: {region}")
print(f"Total Sales: ${total_sales:,.2f}")
print(f"Commission (5%): ${total_sales * 0.05:,.2f}")This produces a clean, professional report output that could easily be part of a business dashboard or printed receipt.
Printing variables in Python might seem simple at first, but mastering different printing methods can make your code cleaner, more readable, and more professional.
Personally, I rely on f-strings for most of my day-to-day work because they are fast, concise, and expressive. However, knowing alternatives like .format() or Template strings gives you flexibility when working across different Python versions or specialized use cases.
You may also like to read:
- Use Built-In Functions in Python
- Difference Between Functions and Methods in Python
- Pass a Function as a Parameter in Python
- Create a Filter() Function in Python Tkinter

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.