Comparing/Referencing Listsm ANSWERED

Sorry everyone

I have worked this out. The more obvious the solution the harder it is for me to find.


I am a little stuck on a python problem that must have an easy answer and I was hoping one of the Gurus could point me in the right direction as I am no python expert.

I have two lists to compare/reference??
code below

import time
from time import localtime
print year
monthname=[“January”, “February”, “March”, “April”, “May”, “June”,
“July”, “August”, “September”, “October”, “November”, “December”,]
print monthname

month is a integer list 1-12 and monthname is a list of 12 strings(obviously).
You should be able to see where I am going with this. Is there an easy way to reference? these lists together so I dont have to do…
if month[0]==1:
etc twelve times
I have had a good look in the python docs but I’m not sure what I am looking for.
Thanking Everybody in Advance
Dr S
PS I have posted this in the python forum as well as the Game Engine

There is at a beginning no

from time import localtime

Does this do what you are looking for

from time import localtime
time = localtime()
year = time[0]
month = time[1]
monthname=["January",  "February", "March",
  "April", "May", "June",
"July", "August", "September",
  "October", "November", "December",]
print year," ",monthname[month]

or not even close ?

posted by newbie

That is exactly what I did after actually thinking properly about my question

monthlib=[“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”,]

For some reason the list index from month goes from 1-12 not 0-11 like the rest of python but yeah great minds think alike

Thanks Heaps for your reply

Dr S