Python Snippets
Search for keywords in files reachable from current directory.
Calculates the date of n days from the given date.
n days from the given date.Checks if all elements in a list are equal.
Checks if all the values in a list are unique.
Generates a list of numbers in the arithmetic progression starting with the given positive integer and up to the specified limit.
Calculates the average of two or more numbers.
Calculates the average of a list, after mapping each element to a value using the provided function.
Splits values into two groups, based on the result of the given filter list.
filter list.Splits values into two groups, based on the result of the given filtering function.
Calculates the number of ways to choose k items from n items without repetition and without order.
k items from n items without repetition and without order.Returns the length of a string in bytes.
Converts a string to camelcase.
Capitalizes the first letter of a string.
Capitalizes the first letter of every word in a string.
Casts the provided value as a list if it's not one.
unlisted: true
Creates a function that will invoke a predicate function for the specified property on a given object.
Chunks a list into smaller lists of a specified size.
Chunks a list into n smaller lists.
n smaller lists.Clamps num within the inclusive range specified by the boundary values.
num within the inclusive range specified by the boundary values.Inverts a dictionary with non-unique hashable values.
Combines two or more dictionaries, creating a list of values for each key.
Removes falsy values from a list.
Performs right-to-left function composition.
Performs left-to-right function composition.
Groups the elements of a list based on the given function and returns the count of elements in each group.
Counts the occurrences of a value in a list.
Creates a list of partial sums.
Curries a function.
Creates a list of dates between start (inclusive) and end (not inclusive).
start (inclusive) and end (not inclusive).Calculates the date of n days ago from today.
n days ago from today.Calculates the day difference between two dates.
Calculates the date of n days from today.
n days from today.Decapitalizes the first letter of a string.
Deep flattens a list.
Converts an angle from degrees to radians.
Invokes the provided function after ms milliseconds.
ms milliseconds.Converts a dictionary to a list of tuples.
Calculates the difference between two iterables, without filtering duplicate values.
Returns the difference between two lists, after applying the provided function to each list element of both.
Converts a number to a list of digits.
Returns a list with n elements removed from the left.
n elements removed from the left.Returns a list with n elements removed from the right.
n elements removed from the right.Checks if the provided function returns True for every element in the list.
True for every element in the list.Returns every nth element in a list.
nth element in a list.Calculates the factorial of a number.
unlisted: true
Generates a list, containing the Fibonacci sequence, up until the nth term.
Creates a list with the non-unique values filtered out.
Creates a list with the unique values filtered out.
Finds the value of the first element in the given list that satisfies the provided testing function.
Finds the index of the first element in the given list that satisfies the provided testing function.
Finds the indexes of all elements in the given list that satisfy the provided testing function.
Finds the first key in the provided dictionary that has the given value.
Finds all keys in the provided dictionary that have the given value.
Finds the value of the last element in the given list that satisfies the provided testing function.
Finds the index of the last element in the given list that satisfies the provided testing function.
Finds the items that are parity outliers in a given list.
Flattens a list of lists once.
Executes the provided function once for each list element.
Executes the provided function once for each list element, starting from the list's last element.
Creates a dictionary with the unique values of a list as keys and their frequencies as the values.
Converts a date from its ISO-8601 representation.
Calculates the greatest common divisor of a list of numbers.
Initializes a list containing the numbers in the specified range where start and end are inclusive and the ratio between two terms is step.
start and end are inclusive and the ratio between two terms is step.Retrieves the value of the nested key indicated by the given selector list from a dictionary or list.
Groups the elements of a list based on the given function.
Calculates the Hamming distance between two values.
Checks if there are duplicate values in a flat list.
Checks if two lists contain the same elements regardless of order.
Returns the head of a list.
Converts a hexadecimal color code to a tuple of integers corresponding to its RGB components.
Checks if the given number falls within the given range.
Checks if all the elements in values are included in lst.
values are included in lst.Checks if any element in values is included in lst.
values is included in lst.Returns a list of indexes of all the occurrences of an element in a list.
Returns all the elements of a list except the last one.
Initializes a 2D list of given width and height and value.
Initializes a list containing the numbers in the specified range where start and end are inclusive with their common difference step.
start and end are inclusive with their common difference step.Initializes and fills a list with the specified value.
Returns a list of elements that exist in both lists.
Returns a list of elements that exist in both lists, after applying the provided function to each list element of both.
Inverts a dictionary with unique hashable values.
Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).
Checks if the elements of the first list are contained in the second one regardless of order.
unlisted: true
unlisted: true
unlisted: true
Checks if the provided integer is a prime number.
Checks if the given date is a weekday.
Checks if the given date is a weekend.
Converts a string to kebab case.
Checks if the given key exists in a dictionary.
Finds the key of the maximum value in a dictionary.
Finds the key of the minimum value in a dictionary.
Creates a flat list of all the keys in a flat dictionary.
unlisted: true
Returns the last element in a list.
Returns the least common multiple of a list of numbers.
Takes any number of iterable objects or objects with a length property and returns the longest one.
Maps the values of a list to a dictionary using a function, where the key-value pairs consist of the original value as the key and the result of the function as the value.
Creates a dictionary with the same keys as the provided dictionary and values generated by running the provided function for each value.
Returns the maximum value of a list, after mapping each element to a value using the provided function.
Returns the index of the element with the maximum value in a list.
Returns the n maximum elements from the provided list.
n maximum elements from the provided list.Finds the median of a list of numbers.
Merges two or more lists into a list of lists, combining elements from each of the input lists based on their positions.
Merges two or more dictionaries.
unlisted: true
Returns the minimum value of a list, after mapping each element to a value using the provided function.
Returns the index of the element with the minimum value in a list.
Returns the n minimum elements from the provided list.
n minimum elements from the provided list.Calculates the month difference between two dates.
Returns the most frequent element in a list.
Generates a string with the given string value repeated n number of times.
n number of times.Checks if the provided function returns True for at least one element in the list.
True for at least one element in the list.Maps a number from one range to another range.
Moves the specified amount of elements to the end of the list.
Pads a string on both sides with the specified character, if it's shorter than the specified length.
Pads a given number to the specified length.
Checks if the given string is a palindrome.
Converts a list of dictionaries into a list of values corresponding to the specified key.
key.Returns the powerset of a given iterable.
Converts an angle from radians to degrees.
Reverses a list or a string.
Reverses a number.
Converts the values of RGB components to a hexadecimal color code.
Moves the specified amount of elements to the start of the list.
Returns a random element from a list.
Randomizes the order of the values of an list, returning a new list.
Returns a list of elements that exist in both lists.
Converts a string to a URL-friendly slug.
Converts a string to snake case.
Checks if the provided function returns True for at least one element in the list.
True for at least one element in the list.Sorts one list based on another list containing the desired indexes.
Sorts the given dictionary by key.
Sorts the given dictionary by value.
Splits a multiline string into a list of lines.
Flattens a list, by spreading its elements into a new list.
Calculates the sum of a list, after mapping each element to a value using the provided function.
Returns the sum of the powers of all the numbers from start to end (both inclusive).
start to end (both inclusive).Returns the symmetric difference between two iterables, without filtering out duplicate values.
Returns the symmetric difference between two lists, after applying the provided function to each list element of both.
Returns all elements in a list except for the first one.
Returns a list with n elements removed from the beginning.
n elements removed from the beginning.Returns a list with n elements removed from the end.
n elements removed from the end.Returns the binary representation of the given number.
Combines two lists into a dictionary, where the elements of the first one serve as the keys and the elements of the second one serve as the values.
Returns the hexadecimal representation of the given number.
Converts a date to its ISO-8601 representation.
Converts an integer to its roman numeral representation.
Transposes a two-dimensional list.
Builds a list, using an iterator function and an initial seed value.
Returns every element that exists in any of the two lists once.
Returns every element that exists in any of the two lists once, after applying the provided function to each element of both.
Returns the unique elements in a given list.
Returns a flat list of all the values in a flat dictionary.
Returns the weighted average of two or more numbers.
Tests a value, x, against a testing function, conditionally applying a function.
x, against a testing function, conditionally applying a function.Converts a given string into a list of words.
Last updated
Was this helpful?