Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionary (next)
#7
OK, thanks for the suggestions.
They confirm what i found, that the most "direct" way to do it,
is with a value "list" alongside the "dict". (That again is straightforward to make)
Then a simple def() will do the trick like so:

def previous_next(x):
    p = Rlist.index(x)
    prev = dictArabic[Rlist[p-1]]
    nxt = dictArabic[Rlist[p+1]]
    return nxt + prev  # being strings like 'X' , or 'M'...
(One could even do this in less lines of code.)
For those interested, if your conversion of '1999' comes out as 'MCMXCIX',
you're on the right track. Smile
Paul
Reply


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

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