generic_drugs_mapping={'MORPHINE':[86],
'OXYCODONE':[87],
'OXYMORPHONE':[99],
'METHADONE':[82],
'BUPRENORPHINE':[28],
'HYDROMORPHONE':[54],
'CODEINE':[37],
'HYDROCODONE':[55]}
How do I return 86?
This does not seem to work:
print generic_drugs_mapping['MORPHINE'[0]]
You have a bracket in the wrong place:
print generic_drugs_mapping['MORPHINE'][0]
Your code is indexing the string 'MORPHINE', so it's equivalent to
print generic_drugs_mapping['M']
Since 'M' is not a key in your dictionary, you won't get the results you expect.
The list is the value stored under the key. The part that gets the value out is generic_drugs_mapping['MORPHINE'] so this has the value [86]. Try moving the index outside like this :
generic_drugs_mapping['MORPHINE'][0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With