Sep-20-2019, 08:26 AM
(Sep-20-2019, 08:05 AM)perfringo Wrote:(Sep-20-2019, 07:57 AM)YoungGrassHopper Wrote: I am struggling with getting the chunks joined in list form after they get divided in workable chunks of [['A','A','A'],['B','B','B'],['C','C','C']]
I need to get them like this : [['AAA'],['BBB'],['CCC']]
I tried ''.join(chunks) but to luck
My personal feeling is that you should clearly articulate (in spoken language) what you want achieve and then start to implement steps to reach your goal. Do you really need this structure? Not that this is particularly hard to implement (you need to add pair of squared brackets) but why you need it?
chunks = [[dna[y-x:y]] for y in range(x, len(dna)+x, x) if len(dna[y-x:y]) == 3]
Well I know there is probably a easier way to achieve it, but this is the best way I could come up with, ive only been coding for 2 weeks now so that's quite likely the reason I am not finding the most efficient way of going about it.
What I need to achieve:
DNA Input: ATTATTATT
Output: III (representing: Isoleucine, Isoleucine, Isoleucine )
I need to take in a arbitrary length dna sequence from user . So I can get AAAB or AAABBBCC etc.
I need to chop it in workable chunks of 3
I need to check if the codons in the sequence given by the user, matches any of the amino acids I need to check for that is why I am trying a for loop.
The elif statements below the for loop then "checks" the counter and displays if a codon matched any of the aminos I am checking for.
But like I said, I know my approach can be very inefficient and flawed