Dictionary counter
<p>Let's say I have a sequence "ADFG"
The script should see if it's in the list (A,T,G,C) and then if it is, get the key from the dictionary and add 1.
So, for the sequence "ADFG", it would add 1 to variable "a" and to variable "g", and add 2 to variable "error".
However, while the script isn't returning an error, the dicio[i]+=1 line isn't adding up anything.... Any ideas?
I know there are simpler ways to do this but I would like to use a dictionary.</p>

<pre><code>seq= input ("dna seq:").upper()  
a,t,g,c,error=0,0,0,0,0
dicio= {"A":a,"T":t,"G":g,"C":c}
for i in seq:
    if i in ("A","T","G","C"):
        dicio[i]+=1
        a+=1
    else:
        error+=1

print("A={:.2f} %".format(a/len(seq)*100))
print("T={:.2f} %".format(t/len(seq)*100))
print("G={:.2f} %".format(g/len(seq)*100))
print("C={:.2f} %".format(c/len(seq)*100))
print("Da sequencia,{:.2f} % sao erros".format(error/len(seq)*100))
</code></pre>

<p>I think you're trying to use dictionaries to store the values instead of having <code>a,t,g,c</code> be connected to it and updated at the same time. Here's some code that uses some dictionary features to make it a little more concise: </p>

<pre><code>seq= input ("dna seq:").upper()  
a,t,g,c,error=0,0,0,0,0
dicio= {"A":a,"T":t,"G":g,"C":c}
for i in seq:
    if i in dicio.keys():
        dicio[i]+=1
    else:
        error+=1

for key,value in dicio.items():
    print("{}={:.2f} %".format(key,value/len(seq)*100))

print("Da sequencia,{:.2f} % sao erros".format(error/len(seq)*100))
</code></pre>

python python-3.x dictionary count