Created
October 8, 2021 11:35
-
-
Save e-io/03b0ce3d98cb74e5d3139d65994b7bdc to your computer and use it in GitHub Desktop.
string formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
for m in ['', 'd', 'b', 'o', 'x', 'X', 'e', 'E', '%']: | |
template = 'Hello {0}, your balance is {1:=+16' + m + '}:16{2}' | |
print(template.format('Adam', randint(-1000, 1000), m)) | |
print(f'{randint(-1000, 1000):+}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment