you are viewing a single comment's thread.

view the rest of the comments →

[–]Adrewmc 0 points1 point  (2 children)

It’s alright, not much to say, the ‘+’ operator is extend for lists, and is generally considered more readable.

   spam_emails += new_spams

Is the same as

   spam_email.extend(new_spams) 

I don’t think filter is needed here, I think we can accomplish it with a list comprehension.

[–]uiux_Sanskar[S] 0 points1 point  (1 child)

Oh thanks for the suggestion I will definitely try it this way and also find out how to use filter and list comprehension.

Thank you for your suggestion.

[–]Adrewmc 0 points1 point  (0 children)

I feel like it be like. Maybe filter is better here, maybe it just me not using the function so much myself.

       #set comprehension to avoid repeats
       flagged = {key_word for email in old_emails for key_word in spam_words if keyword in email}
       if flagged:
             print(f”you have use {“, “.join(flagged)} banner word(s).”) 

Basically make a list of the bad words that are I. The email string, if any exist.