Okay I am having trouble changing the inputted roman numeral into arabic number so I can add them up what am I doing wrong?
I know I still have a lot to go but I cannot even get the first steps right.

I am new to python.... so the hard coding I have seen so far is not helping and most coding is from Arabic to roman but i need from Roman to Arabic.

from string import *

"I" == 1
"V" == 5
"X" == 10
"L" == 50
"C" == 100
"D" == 500
"M" == 1000


roman = upper(raw_input("Enter the roman numeral to convert to arabic: "))

"I" == 1
"V" == 5
"X" == 10
"L" == 50
"C" == 100
"D" == 500
"M" == 1000

if roman[0] > roman[1]:
    arabic = roman[0] + roman[1]
    

print "The roman numeral",roman, "Is equal to",arabic

To start, '==' is not how you assign a value to a variable. Use '=' for that, as '==' checks for equality. Change those first few lines that have that (the ones assigning the letter to decimal values). And, you can't assign a int value to a str value. You need to use a variable, like this:

valueI = 1
valueV = 5

A better way of doing this is using a dictionary:

mydict = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 }
# so, mydict['I'] contains the value of 1, and so forth.

Also, 'upper()' is built-in to the str object, so you need to call it by saying

roman = raw_input("Enter the roman numeral to convert to arabic: ").upper()

Try making those changes and then proceeding with the code. Good luck!

Just being my pedantic self, you are changing inputted Roman Numerals to Hindi numbers- the Arabs borrowed the numbers from India (in Arabic they are known as 'Indian numbers' - arqa-m hindiyyah)

Just being my pedantic self, you are changing inputted Roman Numerals to Hindi numbers- the Arabs borrowed the numbers from India (in Arabic they are known as 'Indian numbers' - arqa-m hindiyyah)

I keep trying and trying but I just cannot get the answer to spit out in integers instead of a string...what am i doing wrong>??

Well, int(arabic) should return the numeric value of the str arabic. If that's any help.

Do not forget that anywhere in the string that if a numeral is smaller than the one that comes next, it is subtracted from the the one that comes next:

#
if roman[0] >= roman[1]:
#
arabic = roman[0] + roman[1]
Else
arabic = roman[1] - roman[0]

Or something like that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.