Our fruit guy has a bag of fruit (represented as an array of strings) where some fruits are rotten. He wants to replace all the rotten pieces of fruit with fresh ones. For example, given `["apple","rottenBanana","apple"]` the replaced array should be `["apple","banana","apple"]`. Your task is to implement a method that accepts an array of strings containing fruits should returns an array of strings where all the rotten fruits are replaced by good ones. 

### Notes

- If the array is null/nil/None or empty you should return empty array (`[]`).
- The rotten fruit name will be in this camelcase (`rottenFruit`).
- The returned array should be in lowercase.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures

Starter code: def remove_rotten(bag_of_fruits):
	

Solutions:
def remove_rotten(bag_of_fruits):
	return [x.replace('rotten', '').lower() for x in bag_of_fruits] if bag_of_fruits else []


def remove_rotten(fruit_bag):
	if not fruit_bag:
		return []
	temp = []
	for i in fruit_bag:
		i = i.replace('rotten', '', 1)
		i = i.lower()
		temp.append(i)
	return temp


def remove_rotten(fruits):
	return [f[6].lower() + f[7:] if f[:6] == 'rotten' else f for f in fruits] if fruits else []


import re
rotten_pattern = re.compile('rotten')

def remove_rotten(bag_of_fruits):
	return [re.sub(rotten_pattern, '', fruit.lower()) for fruit in bag_of_fruits] if bag_of_fruits else []


def remove_rotten(bag_of_fruits):
	if bag_of_fruits is None:
		return []
	clean_bag = []
	for fruit in bag_of_fruits:
		if 'rotten' in fruit:
			clean_bag.append(fruit.replace('rotten', '').lower())
		else:
			clean_bag.append(fruit)
	return clean_bag


def remove_rotten(fruits):
	return [f.replace('rotten', '').lower() for f in fruits or []]


def remove_rotten(bag_of_fruits):
	return [i[6:].lower() if i[:6] == 'rotten' else i for i in bag_of_fruits] if bag_of_fruits else []


def remove_rotten(bag_of_fruits):
	return [el.replace('rotten', '').lower() for el in bag_of_fruits] if bag_of_fruits else []


from re import sub

def remove_rotten(bag_of_fruits):
	return [sub('rotten', '', fruit).lower() for fruit in bag_of_fruits] if bag_of_fruits is not None else []


def remove_rotten(bag):
	return [fruit[6:].lower() if 'rotten' in fruit else fruit for fruit in bag] if bag else []