Python ProgrammingPython Programming

Efficient way to add spaces between characters in a string in Python

s = "CANADA"

print(" ".join(s))
print("-".join(s))
print(s.replace("", " ")[1: -1])
Output
C A N A D A
C-A-N-A-D-A
C A N A D A