(self, s)
| 8 | |
| 9 | class Solution(object): |
| 10 | def romanToInt(self, s): |
| 11 | romanDict = {'M':1000, 'D':500, 'C':100, 'L':50, 'X':10, 'V':5, 'I':1} |
| 12 | res, p = 0, 'I' |
| 13 | for ch in s[::-1]: |
| 14 | if romanDict[ch] < romanDict[p]: |
| 15 | res = res - romanDict[ch] |
| 16 | else: |
| 17 | res = res + romanDict[ch] |
| 18 | p = ch |
| 19 | return res |
| 20 | |
| 21 | s = Solution() |
| 22 | print((s.romanToInt("IX"))) |
no outgoing calls
no test coverage detected