Trying to Cut Apart a String Based on a List

I’m trying to write a code that will actively cut apart a peptide sequence based on an enzyme used. I’m able to get the peptide to become cut based on the first value of the list, but not on the second. I don’t fully understand what’s I’m doing wrong, as when I print the Trypsin[Amino] before the while loop, it shows the ‘K’ and the ‘R’, but then the peptide is only cut with the ‘K’. What I’m anticipating are a total of five cuts, ‘PWWK’ ‘IHEGSR’ ‘R’ ‘NQDK’ and then a remainder of HY. I’m still very new to Python, so any help would be appreciated.

AminoString = 'PWWKIHEGSRRDNQDKHY'

Trypsin = ['K', 'R']

TrypsinCleavage = []

TrypRep = 0

for Amino in range(0, len(Trypsin)):

    TrypCount = AminoString.count(Trypsin[Amino])
    FullSeq = AminoString

    while TrypRep < TrypCount:
  
        TrypsinCleavage.append(FullSeq.rsplit(Trypsin[Amino]) [0] + Trypsin[Amino])
        FullSeq = FullSeq.replace(TrypsinCleavage[-1], '')
        TrypRep += 1

What is the result supposed to be? It might be that TrypRep = 0 should be inside the loop, but without knowing what the result should be, I can’t tell.

I appreciate the help and moving the TrypRep into the loop actually solved one issue. I’m expecting five cuts: ‘PWWK’ ‘IHEGSR’ ‘R’ ‘NQDK’ and then a remainder of HY. I’m able to get five cuts in total, [‘PWWK’, ‘IHEGSRRDNQDK’, ‘PWWKIHEGSR’, ‘R’] DNQDKHY when running the updated code, but they’re not cut in a way I’m needing. One solution I can think of is to separate them, one with ‘K’ and one with ‘R’, then compare them and delete the repetitive portions.

Here’s a way to do it:

def find_cuts(amino_string, tryp):
    cuts = []
    pos = 0

    while True:
        next_pos = amino_string.find(tryp, pos)

        if next_pos < 0:
            break

        cuts.append(next_pos + 1)
        pos = next_pos + 1

    return cuts

def find_multiple_cuts(amino_string, trypsin):
    cuts = []

    for tryp in trypsin:
        cuts.extend(find_cuts(amino_string, tryp))

    return sorted(cuts)

amino_string = 'PWWKIHEGSRRDNQDKHY'
trypsin = ['K', 'R']

pos = 0
cuts = []

for p in find_multiple_cuts(amino_string, trypsin):
    cuts.append(amino_string[pos : p])
    pos = p

if pos < len(amino_string):
    cuts.append(amino_string[pos : ])