I am having trouble with some if statements in my script. I run from a terminal using ./iojson.py "nodev", but the code still executes the if statements for "enum" or "snum", which cause my script to stop due to a NameError.
The code is below:
devicelist = sys.argv[1]
if devicelist == "snum" or "enum":
    if devicelist == "snum":
        print("It executed snum")
        with open('SNUM.txt') as f:
            content = f.readlines()
    if devicelist == "enum":
        print("It executed enum")
        with open('ENUM.txt') as f:
            content = f.readlines()
    content = [x.strip() for x in content]
    devices = ''.join(content)
    data['attachments'].append({
        'fields' : [{
            'title' : 'Serial numbers:',
            'value' : devices
            }]
        })
elif devicelist == "nodev":
    print("It executed nodev")
    pass
After execution, the response is:
Traceback (most recent call last):
  File "./iojson.py", line 43, in <module>
    content = [x.strip() for x in content]
NameError: name 'content' is not defined
My understanding though is that it should never have gotten to the content variable in the first place. What am I doing wrong?
 
    