Add Spaces
Add Spaces in Python – (Add Leading, Trailing Spaces to string)
Add Spaces in python at the start of the string:
## Add the space at Start of the string in Python
string2="Test String leading space to be added"
string_length=len(string2)+10 # will be adding 10 extra spaces
string_revised=string2.rjust(string_length)
print (string_revised)
# ‘ Test String leading space to be added’Add white spaces at start and end of the string:
Add spaces in python between every letter of the string:
PYTHON STRINGS TUTORIAL
Last updated