I've got a python script that sets a variable: notes_eo_counter = 0 And then defines a function: def printNotesRow(columns): if columns[3][:31] == 'Automatic person update notice': print "<tr" if (int(notes_eo_counter) % 2): print 'bgcolor="#ffffff">' else: print 'bgcolor="#' + str(session['CRBGColor']) + '">' print '<td class="bodysmall">' + str(context.fixDate(columns[0])) + '</td>' print '<td class="bodysmall">' + columns[1] + '</td>' print '<td class="bodysmall">' + str(columns[3][36:-1]) + '</td>' print '</tr>' notes_eo_counter = notes_eo_counter + 1 return printed And then calls it: newnotesrow = printNotesRow() if newnotesrow: print newnotesrow return printed This has worked just fine in several scripts, but in this particular one I'm gettin an error: Error Type: UnboundLocalError Error Value: local variable 'notes_eo_counter' referenced before assignment Those lines, although blended with many others, are in that order in the code. I don't know how I'm getting this error and it's driving me nuts. The line that the traceback points to is: if (int(notes_eo_counter) % 2): TIA Rick