Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to split a string (input) and each section used as a dictionary value?
    text
    copied!<p>So I want to write a program that checks if the DNA is mutated or not, i'm not quite sure how to explain this, so this is what it says: <br> <strong><em>Write a program to determine if a patient has a mutation in their DNA sequence which results in a change of amino acid sequence. Your program should work like this:</em></strong></p> <pre><code>Enter original DNA: AAT Enter patient DNA: AAC The patient's amino acid sequence is not mutated. Enter original DNA: AATTGTTCTTCT Enter patient DNA: AACTGCAGCTCA The patient's amino acid sequence is not mutated. Enter original DNA: TGTCATGCCTTATTAGAAAACGGTGAG Enter patient DNA: TGTCATGTCTTATTAGAAAAAGGTGAG The patient's amino acid sequence is mutated. </code></pre> <p>And this is part of the text file I use:</p> <pre><code>The mappings from codon to amino acid are available in a file, called codon_amino.txt, an excerpt of which is shown here: AAC N AAG K AAT N GCG A GCT A GGA G GGC G GGG G GGT G </code></pre> <p>So this is my code so far:</p> <pre><code>n = {} for line in open('codons.txt'): codon, codons = line.split() n[codon] = codons org = input('Enter original DNA: ') pat = input('Enter patient DNA: ') if n[org] == n[pat]: print("The patient's amino acid sequence is not mutated.") else: print("The patient's amino acid sequence is mutated.") </code></pre> <p>So my code works OK with the first example, where there are only 3 letters being used, but the next two have more than 3, and I was wondering how I could manipulate my code to work with that too? I hope someone understands this question. Thank you in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload