Skip to content

Instantly share code, notes, and snippets.

@ktprezes
Created April 14, 2019 16:56
Show Gist options
  • Save ktprezes/ac37d990d39b5f2369c89b607022bbf6 to your computer and use it in GitHub Desktop.
Save ktprezes/ac37d990d39b5f2369c89b607022bbf6 to your computer and use it in GitHub Desktop.
Python - how to create empty list / dict / set
# 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