Answers for "insert space in string python"

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

Python Answers by Framework

Browse Popular Code Answers by Language