I can't solve the following problem.
I have a list and items in it. I need to find 3 or more consecutive items and change them.
For example:
mylist = ["BLUE", "BLUE", "RED", "RED", "RED", "RED", "BLACK", "RED", "RED"]
Required output:
mylist = ["BLUE", "BLUE", "WHITE", "WHITE", "WHITE", "WHITE", "BLACK", "RED", "RED"]
There were 4 items found "RED" and changed to "WHITE". Less than 3 "RED" items are unchanged. There may be an elegant solution, but I still can't find it.
Will anyone help?