Python strings do not have an append() method like lists. Strings are immutable, so appending text means creating a new string from the old string plus the new text.
Tested on: Python 3.13.3; kernel 6.14.0-37-generic.
Quick answer: append to a string in Python
Use text += "more" for simple appending. Use text = text + "more" for explicit concatenation. Use f-strings when appending variables into a sentence. Use "".join(parts) when combining many strings.
text = "Hello"
text += " World"
print(text)
name = "Deepak"
age = 32
print(f"My name is {name} and I am {age} years old.")The first block appends literal text. The f-string builds a message with variables in one readable expression.
Python append string quick reference
| Task | Use |
|---|---|
| Append one string | text += " world" |
| Concatenate two strings | result = a + b |
| Append with space | result = a + " " + b |
| Append variable in text | result = f"{name} is {age}" |
| Append non-string value | result = text + str(value) |
| Join many strings | result = "".join(parts) |
| Join with separator | result = " ".join(words) |
| Build string in loop | collect parts in list, then "".join(parts) |
| Append newline | text += "\n" + line |
| Efficient file-like string building | io.StringIO |
| Method that does not exist | str.append() |
Does Python have a string append() method?
No. Python strings do not have append(). append() is a list method, not a string method.
Strings are immutable. Any append-like operation creates a new string and assigns it to a variable. The original string object is not modified in place.
text = "Hello"
text += " World"
print(text)
# This fails — strings have no append()
try:
"Hello".append(" World")
except AttributeError as exc:
print(type(exc).__name__)Append to a string using +=
+= is the most direct way to append a small string. It is shorthand for text = text + new_text. For a broader look at joining techniques, see Python concatenate strings.
message = "Hello"
message += " World"
print(message)Good for simple cases. Remember that Python assigns a new string value; it does not mutate the old string object in place.
Append strings using + operator
+ joins two strings. It does not add spaces automatically, and both operands must be strings.
first = "Hello"
second = "World"
result = first + " " + second
print(result)
age = 32
print("Age: " + str(age))Use str() when you need to append integers, floats, or other non-string values.
Append variables using f-strings
f-strings are usually the cleanest way to build readable strings with variables. They work well for sentences, messages, logs, and labels.
name = "Deepak"
age = 32
message = f"My name is {name} and I am {age} years old."
print(message)
count = 5
print(f"Count: {count}")f-strings were introduced in Python 3.6 and are the preferred choice for most new code.
Append strings using format()
str.format() is useful for older code or when you prefer template-like formatting. It is still valid, but f-strings are usually cleaner in Python 3.6+.
name = "Deepak"
age = 32
message = "My name is {} and I am {} years old.".format(name, age)
print(message)Keep format() for codebases that already use it consistently or when you need reusable format templates.
Append many strings using join()
join() is best when you already have a list or iterable of strings. The separator string goes before .join().
words = ["Hello", "World"]
numbers = ["1", "2", "3"]
print(" ".join(words))
print("".join(numbers))"".join(parts) joins without a separator. " ".join(words) joins with spaces. Every item must be a string, or Python raises TypeError.
Append string in a loop
For a small loop, += is usually fine. For many pieces, collect strings in a list and use "".join(parts) at the end.
# Small loop — += is fine
result = ""
for i in range(5):
result += str(i)
print(result)
# Many pieces — list + join is clearer
parts = []
for word in ["Python", "string", "append"]:
parts.append(word)
sentence = " ".join(parts)
print(sentence)The list approach avoids repeatedly building large temporary strings in memory.
Append string with separator
Use + when manually adding a separator between a few strings. Use join() when appending many items with the same separator.
tags = ["python", "strings", "tutorial"]
csv_manual = tags[0] + "," + tags[1] + "," + tags[2]
csv_join = ",".join(tags)
print(csv_manual)
print(csv_join)join() scales better for comma-separated values, space-separated words, and similar patterns.
Append newline to a string
Use "\n" when appending a single new line. For many lines, collect lines in a list and use "\n".join(lines).
report = "Summary"
report += "\n" + "Line 1"
report += "\n" + "Line 2"
print(report)
lines = ["Error: timeout", "Warn: retry", "Info: done"]
log = "\n".join(lines)
print(log)Useful for reports, logs, and generated text output.
Append non-string values to a string
Python cannot concatenate str and int directly. Convert values with str(), or use f-strings for readability.
count = 42
price = 19.99
print("Count: " + str(count))
print(f"Price: {price:.2f}")f-strings handle conversion for you inside {...} expressions.
Append string to a list vs append to a string
| Task | Method |
|---|---|
| Add string as an item in a list | my_list.append("text") |
| Add text to an existing string | text += "text" |
| Combine list of strings into one string | "".join(my_list) |
items = []
items.append("first")
items.append("second")
print(items)
text = "start"
text += " end"
print(text)
print(" ".join(items))list.append() changes the list in place. String appending creates a new string value.
Append bytes vs append string
Strings and bytes are different types. Do not concatenate str and bytes directly.
text = "Hello"
data = b" World"
combined = text + data.decode("utf-8")
print(combined)
encoded = (text + " World").encode("utf-8")
print(encoded)Decode bytes to str, or encode str to bytes, before combining them.
Which method should you use?
| Situation | Recommended method |
|---|---|
| Add two simple strings | + |
| Add text to existing variable | += |
| Build a message with variables | f-string |
| Support older Python code | format() |
| Combine list of strings | join() |
| Build many lines | list + "\n".join(lines) |
| Very large streaming text | io.StringIO |
For large streaming builds, io.StringIO behaves like an in-memory text buffer:
import io
buffer = io.StringIO()
buffer.write("Line 1\n")
buffer.write("Line 2\n")
print(buffer.getvalue())Summary
Python strings do not have append(). Use += or + for simple appending, f-strings for messages with variables, and join() for many strings. Convert non-string values before concatenating, or use f-strings. For list operations, use list.append(). For splitting strings apart, see Python split string.
References
- Python
str.join()documentation - Python f-strings (PEP 498)
- Python
str.format()documentation - Python
io.StringIOdocumentation

