Created
February 22, 2021 00:41
-
-
Save leveled/267402f0218a01db083d4b68d5901438 to your computer and use it in GitHub Desktop.
Unpacking iterables in Python cheatsheet
This file contains hidden or 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
>>> fruits = ['lemon', 'pear', 'watermelon', 'tomato'] | |
>>> print(fruits[0], fruits[1], fruits[2], fruits[3]) | |
lemon pear watermelon tomato | |
>>> print(*fruits) | |
lemon pear watermelon tomato | |
>>> date_info = {'year': "2020", 'month': "01", 'day': "01"} | |
>>> filename = "{year}-{month}-{day}.txt".format(**date_info) | |
>>> filename | |
'2020-01-01.txt' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment