Python 3.5.2 Roman Numeral Quiz
<p>So I am doing this assignment for school. I have to create a quiz like game that will prompt a user to add roman numerals together and input their answer. It will then check the user's answer with the correct answer and tell the user if they got it right or wrong.</p>

<p>So far I have this:</p>

<pre><code>class RomanNumeral:
    index = 0
    while index &lt; len(integer_list) - 1:
        #if a lower number is first, it should be subtracted, like IX, 
        #the one should be subtracted, but the 10 added
        if integer_list[index] &lt; integer_list[index + 1]:
            r_integer -= integer_list[index]
        else:
            r_integer += integer_list[index]
        index += 1
    #Always add the last number
    r_integer += integer_list[index]
    #Store r_integer as an instance data item
    self.__integer = r_integer
    return

def main():
        roman1 = RomanNumeral('random')
        roman2 = RomanNumeral('random')
        correct_answer = roman1 + roman2
main()
</code></pre>

<p>But when I run it, i get this error:</p>

<pre><code>r_integer += integer_list[index]
UnboundLocalError: local variable 'r_integer' referenced before assignment
</code></pre>

<p>Any suggestions on how to fix this issue? </p>

<p>As well, I need help overloading the <strong>int</strong> method to change the roman numerals to integers so that they can be added together. </p>

<p>Your error says</p>

<pre><code>local variable 'r_integer' referenced before assignment
</code></pre>

<p>This means you tried to use a variable before you defined it. Define <code>r_integer</code> to 0 (or some other number) before the <code>while</code> loop and your problem should be fixed.</p>

python roman-numerals