def remove_credits(text):
 textlines = text.split('\n')
 credits = None
 for i in (0, (-1)):
  if (textlines and ('lyrics' in textlines[i].lower())):
   credits = textlines.pop(i)
 if credits:
  text = '\n'.join(textlines)
 return text

def remove_credits ( text ) : textlines = text . split ( '\n' ) credits = None for i in ( 0 , ( - 1 ) ) : if ( textlines and ( 'lyrics' in textlines [ i ] . lower ( ) ) ) : credits = textlines . pop ( i ) if credits : text = '\n' . join ( textlines ) return text
remove first/last line of text if it contains the word lyrics eg lyrics by songsdatabase .