Skip to content

Instantly share code, notes, and snippets.

@yeaske
Created March 18, 2019 21:00
Show Gist options
  • Save yeaske/ef403c004505e0ad6a77056fbbe6363b to your computer and use it in GitHub Desktop.
Save yeaske/ef403c004505e0ad6a77056fbbe6363b to your computer and use it in GitHub Desktop.
print(f"Total number of elements in list: {len(object_list)}")
# for obj in object_list:
# print(obj)
# Create a set from the list of objects
object_set = set(object_list)
# OR
object_set = {*object_list}
# OR
object_set = set()
for obj in object_list:
object_set.add(obj)
print(f"Total number of elements in set: {len(object_set)}")
# for obj in object_set:
# print(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment