Project censor dispenser

how do I get the function to check every two words and not every one in a email I’m supposed to censor

def censor(email_num):
   for i in email_num:
     if email_num[i]=="learning":

I need to strip ‘learning algorithms’

It sounds like you mean skipping but you probably mean moving the cursor one step forward but looking at two words. <- isn’t that also how you’d do it? count up 0 1 2 3 4 5 … and for each one pick the next two words. When you’re asking how to do it, you’re already saying how to do it…Right? The definition of the thing is the how of it. Computers aren’t special enough to do it any differently.

Also, is your i really a valid index for your email_num? Where did you get i from?

i is just a very common way for iterating in for and while loops in JavaScript. or at least where I learnt it.
you’l just be typing i instead of word, Item and such in a list or a string name

so what you’re basically saying is to to iterate through the words in the email and for every one check it and the following one.

does word in this

for word in email_num:

have a numeral value?

if it does I can do this

for word in email_num:
    if word ='learning' & email_num[word+1]='algorithms':
       email_num.replace(word&email_num[word+1],' ')      

but maybe it will be shorter to just do this since email_one is a single string

def censor(email_num, to_censor):

censor(email_one,'learning algorithms')

I’ll try it and let you know if it works if your interested