Complete the solution so that it strips all text that follows any of a set of comment markers passed in. Any whitespace at the end of the line should also be stripped out. 

**Example:**

Given an input string of:
```
apples, pears # and bananas
grapes
bananas !apples
```

The output expected would be:
```
apples, pears
grapes
bananas
```

The code would be called like so:

```python
result = solution("apples, pears # and bananas\ngrapes\nbananas !apples", ["#", "!"])
# result should == "apples, pears\ngrapes\nbananas"

```

Source: codewars | Difficulty: MEDIUM_HARD
Tags: String algorithms

Starter code: def solution(string,markers):
	

Solutions:
def solution(string, markers):
	parts = string.split('\n')
	for s in markers:
		parts = [v.split(s)[0].rstrip() for v in parts]
	return '\n'.join(parts)


def strip_line(line, markers):
	for m in markers:
		if m in line:
			line = line[:line.index(m)]
	return line.rstrip()

def solution(string, markers):
	stripped = [strip_line(l, markers) for l in string.splitlines()]
	return '\n'.join(stripped)


def solution(string, markers):
	lst = string.split('\n')
	ans = []
	for line in lst:
		for m in markers:
			if m in line:
				line = line[:line.find(m)].strip()
		ans.append(line)
	return '\n'.join(ans)


import re

def solution(string, markers):
	for marker in markers:
		string = re.sub(' *?\\{}.*$'.format(marker), '', string, flags=re.M)
	return string


from re import sub

def solution(string, markers):
	return sub('(.*?) ?([\\%s].*)' % '\\'.join(markers), '\\g<1>', string) if markers else string


def solution(string, markers):
	lst = string.split('\n')
	for (i, s) in enumerate(lst):
		for m in markers:
			f = s.find(m)
			s = s[0:f] if f >= 0 else s[:]
		lst[i] = s.strip()
	return '\n'.join(lst)


def solution(string, markers):
	lines = string.splitlines()
	for mark in markers:
		lines = [line.split(mark)[0].strip() for line in lines]
	return '\n'.join(lines)


from re import escape, sub

def solution(s, markers):
	return s if not markers else sub('( *[{}].*)'.format(escape(''.join(markers))), '', s)


def solution(string, markers):
	content = string.split('\n')
	clean_content = []
	for full_line in content:
		clean_line = ''
		for char in full_line:
			if not char in markers:
				clean_line += char
			else:
				break
		clean_line = clean_line.strip()
		clean_content.append(clean_line)
	return '\n'.join(clean_content)