```
def romanToInt(self,s):
if not s:
return 0
result=0
map={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
length=len(s)
old=map[s[length-1]]
for i in range(1,length):
current=map[s[length-1-i]]
if current>=old:
result+=old
old=current
else:
old-=current
print(result+old)
```

I was doing addition from right to left. while i found any numeral smaller than the previous one (that has not been processed), it means a subtraction.

i.e.:

IIV means 3, VIIIV means V(IIIV) not (VIII)V.

But i am not sure if this is indeed the rule for roman numerals? Always perform from right to left and do subtraction before addition?