Possible Duplicate:
How to find positions of the list maximum?
A question from homework:
Define a function censor(words,nasty)
that takes a list of words, and
replaces all the words appearing in nasty with the word CENSORED, and
returns the censored list of words.
>>> censor([’it’,’is’,’raining’], [’raining’])
[’it’,’is’,’CENSORED’]
I see solution like this:
- find an index of
nasty
- replace words matching that index
with
"CENSORED"
but i get stuck on finding the index..