-
-
Save pjastr/d42d937c7b00b80b5dfe309b4ac0e854 to your computer and use it in GitHub Desktop.
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
# source: https://realpython.com/python-formatted-output/#the-python-string-format-method | |
print('{quantity} {item} cost ${price}'.format(quantity=6, item='bananas', price=1.74)) | |
print('{0}/{1}/{2}'.format('foo', 'bar', 'baz')) | |
print('{2}.{1}.{0}/{0}{0}.{1}{1}.{2}{2}'.format('foo', 'bar', 'baz')) | |
# print('{3}'.format('foo', 'bar', 'baz')) | |
print('{}/{}/{}'.format('foo', 'bar', 'baz')) | |
# print('{}{}{}{}'.format('foo','bar','baz')) | |
print('{}{}'.format('foo', 'bar', 'baz')) | |
# print('{1}{}{0}'.format('foo','bar','baz')) | |
print('{x}/{y}/{z}'.format(x='foo', y='bar', z='baz')) | |
# print('{x}/{y}/{w}'.format(x='foo', y='bar', z='baz')) | |
print('{0}/{1}/{2}'.format('foo', 'bar', 'baz')) | |
print('{0}/{1}/{2}'.format('bar', 'baz', 'foo')) | |
print('{x}/{y}/{z}'.format(x='foo', y='bar', z='baz')) | |
print('{x}/{y}/{z}'.format(y='bar', z='baz', x='foo')) | |
print('{0}{x}{1}'.format('foo', 'bar', x='baz')) | |
# print('{0}{x}{1}'.format('foo', x='baz', 'bar')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment