I want to remove all of the trailing whitespace from each element in a list, but strip()
and rstrip()
don't seem to be doing the trick.
Each element in the list looks like this, but with many more lines of nucleotide sequence:
>gi|317176027|dbj|AB558126.1| Apis mellifera shade mRNA, unspliced mRNA of CYP314A1 CTCTCACGTCGGAATTGACGGCCGCCAGTACGGTCCTTGGCTTTTTCCCGGCACTGAATATCGTCGCAGA TTCGTTCATCGAGTTGATCCGTCGTCAAAGAGTCGGATACAAAGTGACAGGTTTCGAAGAGCTCGCCTAT AAAATGGGATTGGAGAGTAAGATTTAACCCCCCTCCCCCCAACTTCAATATAGTTTTATCGATTTTATCC
What I'm trying to do is iterate over each element in the list and return a sequence as a string, however I need to remove all the whitespace from each of the lines in my list elements. I know this should be a pretty simple task, but I can't seem to figure out why my code isn't working.
This (and each commented out version) returns the exact same thing I have above.
for i in genelist:
j = i.rstrip()
#j = i.rstrip('\r\n')
#j = i.strip()
#j = i.strip('\r\n')
print(j)
You can remove newlines with i.replace('\n', '')