Use + operator or join method to append a character into a string Python. Using the +
operator: The +
operator can be used to concatenate two strings together. To append a character to a string, you can simply concatenate the character with the string.
Example append a character to string Python
A simple example code appends a string to another string in Python. The Python string is an immutable object, so any methods that perform some action on a string return a new string.
Using + Operator
It concatenates two strings or a string and a character and returns a new string in Python.
s = "Hell"
c = "o"
print(s + c)
Output:
Using the join() Method
The string.join() method concatenates all the iterable object elements using the string as a separator between the elements.
s = "Hell"
c = "o"
res = "".join((s, c))
print(res)
Output: Hello
Do comment if you have any doubts or suggestions no this Python append char topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.