How to add padding to a string in Python

1 Answer

0 votes
s = 'abc'
 
padding = '*'
 
length = 9
  
s = s.rjust(length, padding)
 
print(s)
  
  
  
'''
run:
  
******abc
 
'''

 



answered Sep 20, 2023 by avibootz
edited Sep 21, 2023 by avibootz

Related questions

1 answer 132 views
132 views asked Sep 21, 2023 by avibootz
1 answer 161 views
1 answer 214 views
3 answers 250 views
...