Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionary (next)
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 ?


Messages In This Thread
Dictionary (next) - by DPaul - May-03-2020, 07:16 AM
RE: Dictionary (next) - by pyzyx3qwerty - May-03-2020, 07:26 AM
RE: Dictionary (next) - by DPaul - May-03-2020, 07:31 AM
RE: Dictionary (next) - by ndc85430 - May-03-2020, 07:32 AM
RE: Dictionary (next) - by bowlofred - May-03-2020, 07:34 AM
RE: Dictionary (next) - by buran - May-03-2020, 07:39 AM
RE: Dictionary (next) - by DPaul - May-03-2020, 08:23 AM

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020