title: Python NameError: Name is not defined Linux
body: <p>I'm getting a weird error on some of my scripts. These worked like last week with the same code.</p>
  
  <p>My code:</p>
  
  <pre><code>import ipaddress
  import csv
  from csv import DictReader, DictWriter
  import operator
  import time
  import os
  import datetime
  from datetime import datetime
  
  cnt=1
  
  FMT='%a %b %d %H:%M:%S %Y'
  
  start_time=str(time.strftime("%c", time.localtime()))
  
  forpth=r'/home/path/Geo_Assigned'
  
  forfiles=[os.path.join(forpth, fname) for fname in os.listdir(forpth)if fname.startswith('DC')]
  forlat=max(forfiles, key=os.path.getmtime)
  
  mskcmlst=['255.255.255.254', '255.255.255.252', '255.255.255.248', '255.255.255.240', '255.255.255.224', '255.255.255.192', '255.255.255.128', '255.255.255.0', '255.255.254.0', '255.255.252.0', '255.255.248.0', '255.255.240.0', '255.255.224.0', '255.255.192.0', '255.255.128.0', '255.255.0.0', '255.254.0.0', '255.252.0.0', '255.248.0.0', '255.240.0.0', '255.224.0.0', '255.192.0.0', '255.128.0.0', '255.0.0.0']
  
  
  alphlst=[]
  WaitList=[]
  
  cmpmask=ipaddress.ip_address('255.255.255.254')
  
  msk32=ipaddress.ip_address('255.255.255.255')
  
  n=0
  
  with open(forlat, newline='') as fin:
  
      read = DictReader(fin)
  
      for line in read:
          line['CIDR']=ipaddress.ip_network(line['CIDR'])
          line['Mask']=line['CIDR'].netmask
          lwmask=str(line['Mask'])
          alphlst.append(line)
          print(lwmask)
  
  
  
  print("This is lowest mask: {}".format(lwmask))
  
  endnum=mskcmlst.index(lwmask)+1
  
  print("This is endnum {}".format(endnum))
  </code></pre>
  
  <p>And I am getting the error:</p>
  
  <pre><code>  File "Vtst-linux.py", line 46, in &lt;module&gt;
      print("This is lowest mask: {}".format(lwmask))
  NameError: name 'lwmask' is not defined
  </code></pre>
  
  <p>I am getting this error on Linux Ubuntu Python versions 3.4.1 and 3.4.0 but not Windows on with the same Python versions. I have tried this on virtual environments on the Linux server and just running it from the install path with the same results. The input file is basically a bunch of IP networks in CIDR notation.</p>
  
  <p>Any help is appreciated, I am baffled by this and I have tried changing the variable name and other things and it hasn't helped.</p>