python - Removing an element from a list based on a predicate -
I want to remove an element from the list, such as element 'X' or 'N' . I have to apply for a large genome. Here's an example:
Input:
codon = ['AAT', 'XAC', 'ANT', 'TTA Expected output: codon = ['AAT', 'TTA']
for the base purpose
& gt; & Gt; & Gt; ['AAT', 'TTA']] ['AAT', 'TTA'] ['AAT', 'TTA'] [x] if x is not in x and x is not "x" for x in ['AAT', 'XAC', 'ANT'] 'TTA' / Pre> But if you have a large amount of data, then I recommend that you dict or set
and if you have many letters other than X and N, then you You can do this
& gt; & Gt; & Gt; [X for X for X ['AAT', 'XAC', 'ANT', 'TTA'] if none (for f in the list f (x) if ["x", "n", "y "Note: List (x) may just be x , and [" X "," N "," Y "," Z "," K "," J "] can simply be " XNYZKJ ", and the answer to JeanBuller, he did the best.
Comments
Post a Comment