My program should have a single input where you write either an arabic number, a roman number, or adding roman numbers. For example:
Year: 2001
... MMI
Year: LX
... 60
Year: MI + CI + I
... MCIII
Year: ABC
... That's not a correct roman numeral
Well, I guess you get the deal. First, I tried with something like this:
def main():
year = input ("Year: ")
if type(int(year)) == type(1):
arab_to_rome(year)
else:
rome_to_arab(year)
main()
This have obvious problems, firstly, everything else than an integer will be considered as roman numerals and it doesn't take addition in consideration.
Then I googled and found something called isinstance. This is the result of trying that:
def main(input):
year = input ("Year: ")
if isinstance(input,int):
arab_to_rome(year)
elif isinstance(input,str):
rome_to_arab (year)
else:
print ("Error")
main()
This has problems as well. I get an error message stating: Invalid syntax.
This code doesn't take addition in consideration either.