Created
April 14, 2019 16:56
-
-
Save ktprezes/ac37d990d39b5f2369c89b607022bbf6 to your computer and use it in GitHub Desktop.
Python - how to create empty list / dict / set
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
# creating empty objects | |
empty_l = [] # list | |
empty_d = {} # dictionary | |
empty_s1= set() # set | |
# type check method #1 | |
type(empty_l) | |
type(empty_d) | |
type(empty_s1) | |
# type check method #2 | |
empty_l.__class__ | |
empty_d.__class__ | |
empty_s1.__class__ | |
# alternative methods of creating empty set | |
empty_s2 = {*{}} | |
empty_s3 = {*[]} | |
empty_s4 = {*()} | |
empty_s5 = {0}-{0} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment