Sep-17-2021, 03:06 PM
Yes, you are correct. I need to pass a selector to the function. I just didn't know how far I wanted to go with this example. I always try to return a data type that gives the user the option to do what they want with it. Like returning formatted strings is a terrible idea.
I should have returned a list. Then filtered the duplicates by converting it to a set, outside a function.
I will make some adjustments to my code based on your suggestions.
I need to focus on reusable code and return basic data types.
I use comprehension when I need to filter and map at the same time. Even at the cost of a little overhead.
That type of thing.
I should have returned a list. Then filtered the duplicates by converting it to a set, outside a function.
I will make some adjustments to my code based on your suggestions.
I need to focus on reusable code and return basic data types.
I use comprehension when I need to filter and map at the same time. Even at the cost of a little overhead.
list_multiply = [1, 2, 3, 4, 5, 6, 7, 8] list_inter = [ x * x for x in list_multiply if x > 2]instead of using the map and filter functions
That type of thing.