Start of main content## Python Snippets

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.

### Sum of powers

Python, Math

Returns the sum of the powers of all the numbers from

`start`

to`end`

(both inclusive).### Integer to roman numeral

Python, Math

Converts an integer to its roman numeral representation. Accepts value between

`1`

and`3999`

(both inclusive).### String to words

Python, String

Converts a given string into a list of words.

### Mapped list average

Python, Math

Calculates the average of a list, after mapping each element to a value using the provided function.

### List difference

Python, List

Calculates the difference between two iterables, without filtering duplicate values.

### Value frequencies

Python, List

Creates a dictionary with the unique values of a list as keys and their frequencies as the values.

### Kebabcase string

Python, String

Converts a string to kebab case.

### Map dictionary values

Python, Dictionary

Creates a dictionary with the same keys as the provided dictionary and values generated by running the provided function for each value.

### Max list value based on function

Python, Math

Returns the maximum value of a list, after mapping each element to a value using the provided function.

### Min list value based on function

Python, Math

Returns the minimum value of a list, after mapping each element to a value using the provided function.

### Sum list based on function

Python, Math

Calculates the sum of a list, after mapping each element to a value using the provided function.

### List symmetric difference

Python, List

Returns the symmetric difference between two iterables, without filtering out duplicate values.

### Tip: You should use dict.get(key) instead of dict[key]

Python, Dictionary

Learn the difference between two common ways to access values in Python dictionaries and level up your code today.

Python provides two distinct comparison operators for different task. Stop mixing them up using this quick guide.

### Test if every list element is truthy

Python, List

Checks if the provided function returns

`True`

for every element in the list.