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.
So far I have this:
class RomanNumeral:
index = 0
while index < 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] < 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()
But when I run it, i get this error:
r_integer += integer_list[index]
UnboundLocalError: local variable 'r_integer' referenced before assignment
Any suggestions on how to fix this issue?
As well, I need help overloading the int method to change the roman numerals to integers so that they can be added together.