Python - Insert character at beginning of string


Insert character at beginning of String

To insert a character at start of string in Python, we can use String Concatenation Operator. Pass the specific character as left operand, and the string as right operand. The concatenation operator returns a new resulting string, with the character inserted at the start of the original string.

The syntax to insert character ch at the starting of string x is

ch + x

Example

In the following program, we take a string in x and character in ch, and prepend the character to the starting of the string.

Python Program

x = 'apple'
ch = 'm'
output = ch + x
print(output)

Output

mapple

Summary

In this tutorial of Python Examples, we learned how to insert a character at the starting of string using String Concatenation Operator, with the help of well detailed examples.