def do_work():
medications_subset2(b,['HYDROCODONE','MORPHINE','OXYCODONE'])
def medications_subset2(b,drugs_needed):
MORPHINE=['ASTRAMORPH','AVINZA','CONTIN','DURAMORPH','INFUMORPH',
'KADIAN','MS CONTIN','MSER','MSIR','ORAMORPH',
'ORAMORPH SR','ROXANOL','ROXANOL 100']
print drugs_needed[1][0]
如何打印ASTRAMORPH
(这是MORPHINE
)
我需要使用drugs_needed
,因为这是从do_work
传递的
答案 0 :(得分:4)
你能用这种方式定义MORPHINE吗?
drugs = {
'MORPHINE': ['ASTRAMORPH',...],
'HYDROCODONE': [...],
...
}
然后你可以通过
来引用它print ( drugs[drugs_needed[1]][0] )