Skip to content

Instantly share code, notes, and snippets.

@Nashpratim
Created December 2, 2020 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nashpratim/b879118bc36a4b054d9645041197f4cb to your computer and use it in GitHub Desktop.
Save Nashpratim/b879118bc36a4b054d9645041197f4cb to your computer and use it in GitHub Desktop.
Created on Skills Network Labs
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MichaelCurrin
Copy link

Thanks for sharing.

It would be nice to put these closer together in terms of layout. There are some other methods and pictures between then which makes it hard to connect that these two are equivalent.

>>> a & b
{'AC/DC', 'Back in Black'}
a.intersection(b)
{'AC/DC', 'Back in Black'}

Also, fun fact - the first approach only works if b is a set. But the second approach takes an iterable, so b could be a list, tuple or set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment