Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Last active June 29, 2020 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/5c37c493e08fece36ef3fe7593e8d610 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/5c37c493e08fece36ef3fe7593e8d610 to your computer and use it in GitHub Desktop.
s1="HelloWorld!"
print (s1.rjust(20,"*"))#Output:*********HelloWorld!
print (s1.ljust(20,"*"))#Output:HelloWorld!*********
print (s1.center(20,'*'))#Output:****HelloWorld!*****
#original string is returned,since width(10) specified is less than len(s1)
print (s1.center(10,'*'))#Output:HelloWorld!
print (s1.rjust(10,"*"))#Output:HelloWorld!
print (s1.ljust(10,"*"))#Output:HelloWorld!
#fillchar is not mentioned. default fillchar is an ASCII space
print(s1.center(30))#Output: HelloWorld!
print(s1.rjust(30))#Output: HelloWorld!
print (s1.ljust(30))#Output:HelloWorld!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment