This is a project I'm working on for a class. I'm pretty new to CS and python...and I found that I am totally lost. I'm suppose to write a program to convert Roman numerals to arabic numbers. It is also suppose to handle invalid input.
Here is what I have so far:
def roman_converter():
R=str.upper(raw_input("Enter a Roman numeral to convert to Arabic: "))
d={'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M':1000}
s=0
for c in range(len(R)):
while R[0]<R[1]:
x=R[1]-R[0]
s=s+x
else:
x=R[0]+R[1]
s=s+x
R=R[2:]
else:
return s
print R, '=', s
roman_converter()
I'm getting all sorts of errors with this, and I don't know what to do about the handling of invalid input... help please!