tags:

views:

40

answers:

1
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]

how do i print ASTRAMORPH (this is the first element in MORPHINE)

i NEED to make use of drugs_needed, since this is being passed in from do_work

+4  A: 

Can you define MORPHINE this way?

drugs = {
  'MORPHINE': ['ASTRAMORPH',...],
  'HYDROCODONE': [...],
  ...
}

then you can refer to it by

print ( drugs[drugs_needed[1]][0] )
KennyTM
thank you very much. using this would how can iterate on all drugs in the morphine class?
I__
@l: `for drug in drugs[drugs_needed[1]]: ...`
KennyTM
THANK YOU VERY MUCH GOOOOOOOOD SIR
I__
@KennyTM: can you help with this http://stackoverflow.com/questions/3356209/python-complicated-loop-through-list
I__