About this question
How do you print a variable along with a string in Python? What different methods, like concatenation, f-strings, or format(), can be used to display values clearly?
How do you print a variable along with a string in Python? What different methods, like concatenation, f-strings, or format(), can be used to display values clearly?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask Python Expert
Answered on Aug 26, 2025
When coding in Python, you’ll often need to display variables alongside descriptive text. This raises the question: “How do I print a variable and a string in Python?” Fortunately, Python offers multiple ways to achieve this, ranging from simple concatenation to modern f-strings.
Method 1: String Concatenation
You can join strings with the + operator, but you must convert non-strings using str():
name = "Alice"
print("Hello " + name)Method 2: Comma in print()
The print() function accepts multiple arguments separated by commas. It automatically adds spaces and converts variables to strings:
age = 25
print("Age is", age)Method 3: str.format() Method
Introduced in Python 3, this method allows placeholders inside strings:
score = 95
print("Your score is {}".format(score))Method 4: f-Strings (Best and Recommended)
Available in Python 3.6+, f-strings provide the cleanest syntax for embedding variables directly:
city = "New York"
print(f"I live in {city}")Method 5: Percent Formatting (Older Style)
Though less common today, you can use %:
price = 9.99
print("Price: %.2f" % price) Key Takeaway:
While Python supports multiple methods, f-strings are the most modern, readable, and efficient way to print variables with strings. They make your code concise and easy to maintain.
Lylybrown Latest answer
Answered on Jun 13, 2026
A simple and modern way is to use f-strings, such as print(f"Retro Bowl player: {player_name}"), because they are easy to read and write. You can also use string concatenation ("Retro Bowl player: " + player_name) when working with strings only, or the format() method ("Retro Bowl player: {}".format(player_name)) for compatibility with older Python code. Each method works, but f-strings are generally the most concise and readable option when displaying Retro Bowl statistics, player names, or scores.
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Most-read guides across JanBask
Common Python interview questions, answered
Guides, tips and career advice on Python from JanBask experts.
Python How to Become a Python Developer: A Step-by-Step Guide for Beginners
Discover how to become a Python Developer via a practical 7-step guide build projects, maintain clean code, practice daily, and…
Python PCEP Certification Guide: Entry-Level Python Programmer Certification
Explore this PCEP certification guide for insights on cost, exam format, passing score, application, training, and study tips.…
Python Top 50+ Python Projects ideas for Beginners to Advanced
Discover innovative Python project ideas, explore advanced Python projects, and find good Python projects for beginners and…
Python How To Comment Out Multiple Lines In Python Like A Pro
Commenting out code is a common practice among programmers. It allows you to temporarily disable parts of your code without…