Iterating and indexing
<p>I am currently stuck with this program. I am attempting to determine the molecular weight of a compound given the molecular equation (only Cs, Hs, and Os). I also am unsure of how to correctly format [index +1], as I am trying to determine what the next character after "x" is to see if it is a number or another molecule</p>

<p>def main():</p>

<pre><code>C1 = 0
H1 = 0
O1 = 0
num = 0

chemicalFormula = input("Enter the chemical formula, or enter key to quit: ")
while True:
    cformula = list(chemicalFormula)
    for index, x in enumerate(cformula):
        if x == 'C':
            if cformula[index + 1] == 'H' or cformula[index + 1] == 'O':
                C1 += 1
            else:
                for index, y in range(index + 1, 1000000000):
                    if cformula[index + 1] != 'H' or cformula[index + 1] != 'O':
                        num = int(y)
                        num = num*10 + int(cformula[index + 1])
                    else:
                        C1 += num
                        break
</code></pre>

<p>this is the error I keep getting</p>

<pre><code>Enter the chemical formula, or enter key to quit: C2
  File "/Users/ykasznik/Documents/ykasznikp7.py", line 46, in main
    for index, y in range(index + 1, 1000000000):
TypeError: 'int' object is not iterable
&gt;&gt;&gt; 
</code></pre>
