Hi,

I am developing an app that will convert Roman numbers into Arabic and vice versa.

Roman to Arabic is easy, the other way around is not so straightforward.

Indeed the "canonical method" dictates that "9" is "IX' and not "VIIII".

The whole thing rests on 2 dictionaries like so:

Question: when i take any key, i need to know the previous one.

What i found has to do with "ordered Dict", but that route will cost me more statements than the module itself = not appealing.

The other solution is to put the values in a list, and sidestep from there to find the previous.

So, is there an(other) obvious way to find a "previous" element from a dict ?

thx,

Paul

I am developing an app that will convert Roman numbers into Arabic and vice versa.

Roman to Arabic is easy, the other way around is not so straightforward.

Indeed the "canonical method" dictates that "9" is "IX' and not "VIIII".

The whole thing rests on 2 dictionaries like so:

Roman = {'M':1000, 'D':500, 'C':100, 'L':50, 'X':10, 'V':5, 'I':1}and its reverse.

Question: when i take any key, i need to know the previous one.

What i found has to do with "ordered Dict", but that route will cost me more statements than the module itself = not appealing.

The other solution is to put the values in a list, and sidestep from there to find the previous.

So, is there an(other) obvious way to find a "previous" element from a dict ?

thx,

Paul