Case conversion Python functions
Learn how to capitalize, camelcase, snake case, and kebab case strings in Python.
The Python snippet collection contains helper functions for Python 3.6. It includes utilities for most common data types, such as primitivies, lists, dictionaries and date objects.
Learn how to capitalize, camelcase, snake case, and kebab case strings in Python.
Learn the difference between Python's built-in list sorting methods and when one is preferred over the other.
There's a good way to test the emptiness of a Python list and a better one. Which one are you using?
Converts a hexadecimal color code to a tuple of integers corresponding to its RGB components and vice versa.
Writing efficient Python code can be tricky. Read how we optimize our list snippets to increase performance using a couple of simple tricks.
Sort a Python list based on another list containing the desired indexes.
Python's f-strings can do a lot more than you might expect. Learn a few useful tips and tricks in this quick guide.
Learn how to find the matching values, indexes or keys in a list or dictionary.
Convert a dictionary to a list of tuples and vice versa.
Invert a dictionary with non-unique hashable values.
Find the list of prime factors of a number, using a simple Python function.
Mutable default arguments can trip up Python beginners and veterans alike. Here's a quick workaround to deal with them.
Using str.lstrip()
to strip a prefix from a string might not be exactly what you're looking for. Here's what you should use instead.
Understand Python's named tuples and start using them in your projects today.
Learn how Python's lists and tuples are different and level up your code today.
Master list initialization, using simple techniques and level up your Python skills.
Learn two ways to format a string in Python with this quick tip.
Filter unique or non-unique values from a list using collections.Counter
.
Learn how to sort a Python dictionary list using a tuple key.
Map a number from one range to another range.
Learn how to calculate the Hamming distance between two values.
Chunks a list into a set amount of smaller lists or into lists of a specified size.
Learn everything you need to know about Python's slice notation with this handy guide.
Find the index of the element with the minimum or maximum value in a list.