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"

```

Difficulty: interview

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(r' *?\{}.*$'.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(r'( *[{}].*)'.format(escape(''.join(markers))), '', s)


def solution(string,markers):
    # split string into lines to process them one after another
    content = string.split("\n")
    
    #process every line by its own and append the clean line to clean_content
    clean_content = []
    for full_line in content:
        
        #appending each char until marker
        clean_line = ""
        for char in full_line:
            
            #check for marker, if no marker add char to clean_line 
            #if char in marker break loop
            
            if not char in markers:
                clean_line += char
            else:
                break
        
        #strip whitespaces
        clean_line = clean_line.strip()

        #add clean line to content
        clean_content.append(clean_line)
        
    return "\n".join(clean_content)