To create a map in Python, you can use the built-in map()
function. This function takes two arguments - a function and an iterable. It applies the function to each element of the iterable and returns a new iterable with the results.
Here's an example of how to create a map that squares each element of a list:
main.py125 chars4 lines
To take unique values in Python, you can use a set
. A set is an unordered collection of unique elements. You can convert a list (or any iterable) to a set to remove duplicates:
main.py133 chars4 lines
Alternatively, you can use a list comprehension to get unique values:
main.py175 chars4 lines
gistlibby LogSnag