Python is now the most used language on GitHub, and handling text is a common task for developers. String concatenation – combining multiple pieces of text into one – is a fundamental operation. For many tasks, programmers must python concatenate strings (the exact phrase appears in searches) to build meaningful output. This article explains five easy methods to join strings in Python. Each approach is shown with examples and backed by references. The goal is to give developers clear, practical ways to merge text and insights on when to use each method.
Python strings are immutable, so naive concatenation can be inefficient. For example, using the + operator is simple but creates a new string every time. In contrast, methods like join() handle multiple strings more efficiently. We will cover the common approaches (+, join(), f-strings, format(), and the % operator) and note performance and use cases. Each section below describes a method, often with sample code, and cites authoritative sources. By the end, developers will understand how to concatenate strings in Python effectively. Read this article from 1Byte to find out more.
Using the + Operator

The simplest way to merge two strings in Python is with the plus sign (+). This operator joins strings end-to-end. For example:
s1 = “Hello”
s2 = “World”
result = s1 + ” ” + s2
print(result) # Output: Hello World
In this code, adding s1 and s2 with + and a space between produces Hello World. The code image below shows a similar example.
Using the + operator in Python directly appends one string to another. In this example, “Software ” + “Engineer” yields the output Software Engineer. This method works on any pair of string operands. It is straightforward and readable, making it a go-to for small tasks.
However, using + in a loop or with many strings can be slow. Since Python strings are immutable, each + creates a new string object. This means repeated concatenation (especially in loops) can use extra memory and time. In practice, + is fine for a few strings. For larger sequences, other methods like join() are recommended. Still, for quick combining of two or three strings, the + operator is the easiest to use.
FURTHER READING: |
1. Ubuntu Install Docker: A Step-by-Step Guide for Beginners |
2. Node JS Hosting: 7 Best Services for Speed and Scalability in 2025 |
3. How Much Does a VoIP Phone System Cost in 2025 |
Using the join() Method
When concatenating many strings at once (for example, all items in a list), the built-in str.join() method is ideal. You call join() on a separator string and pass an iterable of strings. For example, to join words with a space:
words = [“Python”, “is”, “efficient”]
result = ” “.join(words)
print(result) # Output: Python is efficient
This builds one string Python is efficient in a single operation. The join() method avoids creating intermediate strings and is thus very efficient. In fact, documentation notes that join() has high memory efficiency because it constructs the final string in one go. By contrast, concatenating with + is marked low efficiency (it makes new string objects each time).
The join() method concatenates a list of strings using the string it’s called on as a separator. In this code example, string1 = “Generative” and string2 = “AI” are joined by ” “.join(), producing Generative AI. This illustrates how join() works: we call it on a separator string (here a space) and pass the list [“Generative”, “AI”]. The result is a single string with elements separated by that space.
In general, join() is recommended for concatenating multiple strings, especially in performance-sensitive code. The Python style guide (PEP 8) specifically recommends ”.join() in cases where many strings are combined, to ensure linear-time performance. Using join() also lets you easily add any delimiter (space, comma, hyphen, etc.) between items. For example, ” – “.join([“Python”, “is”, “powerful”]) yields Python – is – powerful. The method does raise a TypeError if any item is not a string, but this can be resolved by converting with str() first (e.g. using a generator expression). Overall, join() is fast, memory-friendly, and great for combining lists or large numbers of strings.
Using f-Strings (Formatted String Literals)
Introduced in Python 3.6, f-strings offer a concise way to embed variables and expressions inside string literals. They are often used as a form of concatenation when you need to include dynamic content. An f-string is written with an f prefix and braces {} around expressions. For example:
first = “Jane”
last = “Doe”
full = f”{first} {last}”
print(full) # Output: Jane Doe
Here the names are inserted into the string, creating Jane Doe. F-strings automatically convert values to strings, so you don’t need to call str() explicitly.
F-strings are not only easy to read and write, but also very efficient. In performance comparisons, f-strings tend to be faster than the old % operator (printf-style) and faster than using + for two or three strings. One benchmark (for concatenating two strings) reported f-strings at ~110 ns versus % at ~160 ns and + at ~176 ns (with join() around 130 ns). More generally, DigitalOcean notes that join() is most efficient for many strings, followed closely by f-strings for formatted text. This means f-strings are a top choice when you need to build a string with variables.
Beyond simple concatenation, f-strings allow complex expressions and formatting inside the braces. For instance, f”Items: {‘,’.join(items)}” could combine join() and f-strings. They are also recommended for new code and have become Python’s preferred way to format strings (PEP 498). In summary, f-strings provide a powerful and speedy way to python concatenate strings with variables, offering both clarity and good performance.
Using the str.format() Method
The format() method on strings is another way to combine text and variables. It has been available since Python 2.6 and offers flexible formatting. You write a template string with placeholders {} or named fields, and call .format() with values. For example:
s1 = “Hello”
s2 = “World”
s3 = “{} {}”.format(s1, s2)
print(s3) # Output: Hello World
This inserts s1 and s2 into the placeholders in order. You can also use named placeholders: “{a}-{b}”.format(a=s1, b=s2) would put s1 and s2 at {a} and {b} respectively. The code above produces Hello World using format.
The format() method is very powerful for dynamic strings. It can do more than simple concatenation (like number formatting or padding), but it can also serve to join text. For example, “{in1} {in2}”.format(in1=s1, in2=s2) also gives Hello World (as shown in the reference output). DigitalOcean comments that the format() function is useful when working with dynamic values.
In terms of performance, format() creates intermediate objects so it is not as fast as f-strings or join(). DigitalOcean’s summary shows format() marked as “Moderate” performance. For most tasks, it is fine, but if speed is critical and you have Python 3.6+, f-strings are usually preferred. Still, format() is very common in existing code and is more flexible than the % operator. It also automatically calls str() on non-string arguments. In practice, use format() when you need its formatting features (like number formatting) or if you prefer it for readability. Otherwise, for simple concatenation, f-strings or join() are often better.
Using the % Operator (Old-Style)

The % operator (printf-style) is the old way to format strings in Python. It can also concatenate by formatting strings into a template. For example:
s1 = “Hello”
s2 = “World”
s3 = “%s %s” % (s1, s2)
print(s3) # Output: Hello World
Here %s placeholders are replaced by s1 and s2. This prints Hello World. You can mix types, e.g. “%s %d” % (name, age) will convert and insert a number. The example image below shows the % operator usage:
This screenshot demonstrates string concatenation with the % operator. The code print(“%s %s” % (string1, string2)) merges string1 and string2 into one line (here Generative AI).
The % method is now considered somewhat outdated, but it still appears in legacy code. It is generally less recommended for new code, since f-strings and format() are more powerful and safer. In performance terms, the old-style formatting is usually a bit slower than f-strings and join() but faster than multiple + operations for a couple of values. For example, a very small test showed % at around 160 ns versus f-string at 110 ns for a two-string concatenation. In summary, % can concatenate and format, but most modern code uses f-strings or format() instead. It’s good to know % when reading older code, but new development typically prefers the newer methods.
Leverage 1Byte’s strong cloud computing expertise to boost your business in a big way
1Byte provides complete domain registration services that include dedicated support staff, educated customer care, reasonable costs, as well as a domain price search tool.
Elevate your online security with 1Byte's SSL Service. Unparalleled protection, seamless integration, and peace of mind for your digital journey.
No matter the cloud server package you pick, you can rely on 1Byte for dependability, privacy, security, and a stress-free experience that is essential for successful businesses.
Choosing us as your shared hosting provider allows you to get excellent value for your money while enjoying the same level of quality and functionality as more expensive options.
Through highly flexible programs, 1Byte's cutting-edge cloud hosting gives great solutions to small and medium-sized businesses faster, more securely, and at reduced costs.
Stay ahead of the competition with 1Byte's innovative WordPress hosting services. Our feature-rich plans and unmatched reliability ensure your website stands out and delivers an unforgettable user experience.
As an official AWS Partner, one of our primary responsibilities is to assist businesses in modernizing their operations and make the most of their journeys to the cloud with AWS.
Conclusion
All five methods above can concatenate strings in Python. Use the + operator for simple, quick combinations of a few strings. It is easy and clear, but may be inefficient if overused in loops. For joining lists or many strings, the join() method is best: it is fast and uses less memory. When building strings with variables, Python 3’s f-strings are concise and fast. The .format() method works well too, especially if you need advanced formatting features, although it is slightly slower. The % operator is the old style: it still works for combining strings and formatting, but f-strings or format() are generally preferred now.
Key takeaways: To python concatenate strings, developers have versatile options:
- Use + for a few literal strings or simple cases (e.g. “Hello” + “World”).
- Use “separator”.join(list_of_strings) to merge many strings efficiently.
- Use f-strings (f”…{var}…”) for clear, fast interpolation of variables.
- Use str.format() when you need its formatting power (e.g. padding, number formats).
- The % operator is the legacy way; it still concatenates but is mostly superseded by f-strings and format().
Each method has its place. By knowing these five techniques, Python developers can choose the most appropriate and efficient way to combine text for any project. Citing recent tutorials and style guides ensures these recommendations align with current best practices and performance findings.