Answers for "python add space between characters in string"

1

add whitespaces between char python

s = "BINGO"
print(" ".join(s))
Posted by: Guest on February-23-2020
0

add space before and after string python

using re adds white-space before and after the desired characters:

import re

pat = re.compile(r"([.()!])")
print (pat.sub(" \1 ", string))
# hello .  .  .   ( world )  !
Posted by: Guest on March-20-2021

Code answers related to "python add space between characters in string"

Python Answers by Framework

Browse Popular Code Answers by Language