Python Snippets
Python Set Operators
In this post we cover shorthand operators for performing set operations in Python. We'll look at the three most common ones: union, intersection, and difference.
Python Snippets
In this post we cover shorthand operators for performing set operations in Python. We'll look at the three most common ones: union, intersection, and difference.
Python Snippets
Python lists have a handy method called reverse, but it's not always what we want. For a start, we can't use it on other sequence types, like tuples and strings, and it also performs an in-place modification of the original sequence. Using slices we can get around these limitations, reversing
Python Snippets
Get familiar with the different uses for else in Python. It's not just for if statements: we can use it with loops, and for error handling too!