How to add string in front of every character?

95 Views Asked by At

I tried this but I can't.

I want to add "pp" string in front of every character of input.

x=str(input("give me the characters"))
print("pp"+x[0]+"pp"+x[1]+"sa"+x[3])
1

There are 1 best solutions below

0
Andrej Kesely On

You can use str.join to add pp. For example:

x = input("give me the characters: ")
print("pp".join(["", *x]))

Prints:

give me the characters: abcd
ppappbppcppd