How to add a single space in a string in python

Code examples

0
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 )  ! 
0
0

how to add space in python

x = 10
y = x * 0.62
z = y * 2.14

print(str(x) + " " + str(y) + " " + str(z))

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................