Last modified: Apr 25, 2026 By Alexander Williams
Append Char to String Python (6 Methods)
Working with strings is a core part of Python programming. A common task is adding a single character to the end of an existing string. Strings in Python are immutable, meaning you cannot change them in place. Instead, you must create a new string that combines the original content with the new character. This article shows you six clear, simple methods to append a character to a string in Python. Each method includes example code and output to help you understand the process.
1. Using the Plus Operator (+)
The simplest way to append a character is using the + operator. It concatenates the original string with the new character.
# Example using + operator
my_string = "Hello"
my_char = "!"
new_string = my_string + my_char
print(new_string)
Hello!
This method is easy to read and works well for small strings. It creates a new string object each time you use it.
2. Using the join() Method
The join() method is efficient when appending multiple characters. It joins all elements of an iterable into one string.
# Example using join() method
my_string = "Python"
my_char = "3"
new_string = "".join([my_string, my_char])
print(new_string)
Python3
Use join() when you need to append several characters at once. It is faster than repeated + operations for large strings. For more on handling special characters, see our Python Character Encoding Guide for Beginners.
3. Using String Formatting with f-strings
Python 3.6+ offers f-strings, a modern way to embed expressions inside string literals. This method is both readable and efficient.
# Example using f-string
my_string = "Append"
my_char = "X"
new_string = f"{my_string}{my_char}"
print(new_string)
AppendX
F-strings are great for dynamic string building. They handle variable insertion cleanly and support expressions inside curly braces.
4. Using the format() Method
The format() method is another flexible way to build strings. It uses curly braces as placeholders for values.
# Example using format() method
my_string = "Data"
my_char = "!"
new_string = "{}{}".format(my_string, my_char)
print(new_string)
Data!
This method works in all Python versions. It is especially useful when you have multiple placeholders or need positional formatting.
5. Using the % Operator (Old Style)
The % operator, also called string interpolation, is an older but still valid method. It uses %s as a placeholder for strings.
# Example using % operator
my_string = "Code"
my_char = "!"
new_string = "%s%s" % (my_string, my_char)
print(new_string)
Code!
This method is less common in modern code but still appears in legacy projects. It is simple for basic concatenation tasks.
6. Using the str() and Concatenation
If your character is not already a string, use str() to convert it before appending. This ensures type safety.
# Example using str() and concatenation
my_string = "Number"
my_number = 5 # This is an integer, not a string
new_string = my_string + str(my_number)
print(new_string)
Number5
Always convert non-string types to strings before appending. This prevents TypeError and keeps your code robust.
Performance Considerations
For appending a single character, all six methods work well. However, if you need to append many characters in a loop, avoid using + repeatedly. Each + creates a new string, which is slow for large data. Instead, use join() with a list to build the final string efficiently.
# Efficient appending in a loop using join()
chars = ["A", "B", "C"]
result = "".join(chars)
print(result)
ABC
For more advanced string handling, refer to our Python Character Encoding Guide for Beginners to understand how characters are represented.
Common Mistakes to Avoid
Beginners often forget that strings are immutable. Trying to modify a string in place will cause an error. Always assign the result to a new variable. Also, ensure the character is a string type; use str() for integers or other types.
# Wrong: this will raise TypeError
my_string = "Hello"
my_number = 5
# new_string = my_string + my_number # Uncommenting this line causes error
# Correct: convert to string first
new_string = my_string + str(my_number)
print(new_string)
Hello5
When to Use Each Method
Choose the method that fits your context. Use + for simple, one-time appends. Use join() for efficiency with multiple characters. Use f-strings or format() for modern, readable code. The % operator is fine for legacy code. Always convert types with str() when needed.
Conclusion
Appending a character to a string in Python is straightforward with these six methods. Remember that strings are immutable, so each operation creates a new string. The + operator is the simplest, while join() offers better performance for multiple appends. F-strings and format() provide modern, readable alternatives. For type safety, always convert non-string values to strings using str(). Practice these methods to become comfortable with string manipulation in Python. For deeper insights into character handling, check our Python Character Encoding Guide for Beginners.