else: syntax is incorrect
Question: I am a little new to python and I am trying to write this script to cancel
print jobs over 1 mb.. (the line where it is checking for size is set to 1 mb
just to make sure it is working). for some reason my last else statement keeps
saying it has invalid syntax. I checked to see if all parentheses were closed
and I could not find an unmatched pair. could someone please tell me why it
says it is invalid? Also can you take a look at my line 24 (fullname =
...grep...) to make sure the syntax on that is correct?

    
    
    #! /usr/bin/python
    
    import os
    
    infile = open ('test.pl', 'r')
    
    outfile = open('print.reportpython', 'w+')
    
    newfile = infile.readlines()
    
    newfile.pop(0)
    
    count = 0
    
    firstline = newfile[0]
    
    splitline = firstline.split()
    
    currentuser = splitline[1]
    
    currentuser = str(currentuser)
    
    for line in newfile:
    
      newline = line.split()
    
      names = newline[1]
    
      size = int(newline[2])
    
      names = str(names)
    
      print names
    
      if names is currentuser:
    
        if size >= 1:
    
          os.popen ("cancel lab01-10292")
    
      fullname = os.popen("cat /etc/passwd |grep " + newline[1] + "cut -d':' -f5")
    
      count += 1
    
      print count
    
      else:
    
        print outfile.write ("(" + currentuser + ")")
    
        print outfile.write (" ")
    
        count = 0
    
        currentuser = names
    


Answer: You do:

    
    
    if foo:
      bar
    baz
    else:
      bomb
    

Which is wrong. All the lines between the `if` and its corresponding `else`
must be indented deeper than the `if` and `else`, like this:

    
    
    if foo:
      bar
      baz
    else:
      bomb
    

