Sorry for the poor title, basically I want to access a list item based on another list item:
catList = [john, james, jack]
dateList = [1y, 2y, 3m]
for item in catList:
if item in typeList[1]:
calendar += 1
if item in typeList[2]:
connector += 1
print dateList[item]
It’s the last line that I want to achieve, essentially to print the value of dateList which corresponds to the value of catList.
Any ideas? Thanks
Edit: My catDict & dateDict are lists so they don’t have keys, just values.
If the keys to catDict are numeric strings you can use
print dateDict[int(item)]. Otherwise, I’m uncertain – we need to see what the declaration of catDict looks like.If you’re using lists you want to do this: