Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inp = input()
- result = 0
- n = 0
- nprev = 0
- while inp != ".":
- if inp == "I":
- n = 1
- elif inp == "V":
- n = 5
- elif inp == "X":
- n = 10
- elif inp == "L":
- n = 50
- elif inp == "C":
- n = 100
- elif inp == "D":
- n = 500
- elif inp == "M":
- n = 10000
- else:
- print("Invalid symbol")
- break
- result += n
- if nprev < n:
- result -= 2*nprev
- nprev = n
- inp = input()
- if result != 0:
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement