Key in dictionary
Checks if the given key exists in a dictionary.
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.
Checks if the given key exists in a dictionary.
Learn 3 easy ways to swap the values of two variables in Python.
Returns the unique elements in a given list.
Tests a value, x
, against a testing function, conditionally applying a function.
Checks if all elements in a list are equal.
Casts the provided value as a list if it's not one.
Counts the occurrences of a value in a list.
Invokes the provided function after ms
milliseconds.
When working with files in Python, it's important to ensure that the file is closed correctly. Here are a couple of ways to do that.
Checks if there are duplicate values in a flat list.
Returns the head of a list.
Returns all the elements of a list except the last one.
Returns a list of elements that exist in both lists.
Checks if the elements of the first list are contained in the second one regardless of order.
Returns the last element in a list.
Checks if the given string is a palindrome.
Oftentimes you might need to trim whitespace from a string in Python. Learn of three different way to do this in this short guide.
Returns every element that exists in any of the two lists once.
Calculates the date of n
days from the given date.
Clamps num
within the inclusive range specified by the boundary values.
Checks if the given number falls within the given range.
Checks if the provided integer is a prime number.
Pads a given number to the specified length.
Returns the length of a string in bytes.