Skip to content

[LABS] Ricardo map, filter, reduce#14

Open
Ricardo-Beato wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
Ricardo-Beato:main
Open

[LABS] Ricardo map, filter, reduce#14
Ricardo-Beato wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
Ricardo-Beato:main

Conversation

@Ricardo-Beato
Copy link
Copy Markdown

Please see the comments on my solutions, I really struggled with some and even though I think I got the desired result, not sure this is the way and I don't fully understand why my initial approaches did not work. Thanksssss!

@bripollc
Copy link
Copy Markdown

Ricardo,

Sometimes the code can be a bit frustrating, but good job:) It's a matter of trial and error!
I leave you some corrections from the lab:

💥Challenge 1 - Mapping

prophet = prophet[568:]
def reference(x):
    x = x.split("{")
    return x[0]
prophet_reference = list(map(reference, prophet))
print(prophet_reference[0:10])

Everything is well declared and you almost had it! You just needed to use the map() function correctly!
The map function works as follows: : map(fun, iter)

Further on in the exercise, the same thing happens when you try to apply map() to your line_break function.

💥Challenge 2 - Filtering

def word_filter(x):
    word_list = ['and', 'the', 'a', 'an']
    if x in word_list:
        return False
    else:
        return True

Here you did use filter() correctly. But it does not remove the words correctly from word_list because the approach to constructing the word_filter function is not quite correct.

  • Bonus
def word_filter_case(x):
   
    word_list = ['and', 'the', 'a', 'an']
        
    if x.lower() in word_list:
        return False
    else:
        return True

💥Challenge 3 - Reduce

Perfect! Only you don't need to import the functools module again since you have it at the beginning of the notebook.

Don't worry about Challenge 4, we'll see about that in the next few days.

ps: if when printing your answers you limit the range it will be more readable the notebook, jeje 🙃

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants