Add Characters Between Each Character

Add a character between each character.

Logic BuildingIntermediate
Logic Building
# Take string input
s = input("Enter a string: ")
char = input("Enter character to add: ")

# Add between characters
result = char.join(s)
print(f"Result: {result}")

Output

Enter a string: Hello
Enter character to add: -
Result: H-e-l-l-o

Use join() to insert character.

Key Concepts:

  • char.join(s) joins characters
  • Inserts char between each
  • Returns new string