Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Last active June 30, 2020 01:23
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/42adb75456b149deea8f8a19c684280e to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/42adb75456b149deea8f8a19c684280e to your computer and use it in GitHub Desktop.
s1="Hello World!"
print(s1.zfill(20))#Output:00000000Hello World!
#width mentioned is less than len(s1)
print (s1.zfill(12))#Output:Hello World!
#signed prefix
s2="-12"
print (s2.zfill(10))#Output:-000000012
print (s2.zfill(2))#Output:-12
s3="+12"
print (s3.zfill(10))#Output:+000000012
print (s3.zfill(2))#Output:+12+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment