Skip to content

Instantly share code, notes, and snippets.

@horvatha
Created May 31, 2016 17:08
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 horvatha/2a25d9a27606d5cdf9a972f7af5ede20 to your computer and use it in GitHub Desktop.
Save horvatha/2a25d9a27606d5cdf9a972f7af5ede20 to your computer and use it in GitHub Desktop.
# PEP 498 -- Literal String Interpolation
# Works with Python 3.6
i = 6
j = 7
print(f"{i*j} {i+j}")
print('\n'.join(
[
f'{i}x{j}={i*j}' + ('\n' if j == 30 else "")
for i in range(2,21) for j in range(1,31)
]
)
)
harp = {":;": 4}
print(f"{harp[':;']}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment