Cant resolve -> NameError: global name 'plm_description' is not defined

Below is my code:

indent preformatted text by 4 spaces///// def buildPartDict(fbpn):
bom_data = AgileLib(fbpn)
parts_dict = []
for key, values in bom_data.parts.iteritems():
    for part in values:
        parts_dict(fbpn, {'desc': str(plm_description), 'count': 0})['count'] += 1
return parts_dict

I get the following error:


NameError Traceback (most recent call last)
in ()
----> 1 buildPartDict(“01-002014”)

in buildPartDict(fbpn)
4 for key, values in bom_data.parts.iteritems():
5 for part in values:
----> 6 parts_dict(fbpn, {‘desc’: str(plm_description), ‘count’: 0})[‘count’] += 1
7 return parts_dict
8

NameError: global name ‘plm_description’ is not defined

what should I do here? Cant understand.

NameError: global name plm_description is not defined

It means that variable plm_description used here:

parts_dict(fbpn, {'desc': str(plm_description), 'count': 0})['count'] += 1

is simply undefined. It is not defined inside the scope of this function, so it should be defined globally.

What should you do? Take a break and think for a minute what this variable represents and where it should be defined.


You are not an author of this code?