Python: Unresolved reference in try catch

I’m trying to use accumulator (variable) inside the except/else: Updated code classifier = UtteranceClassifier() sc = SparkContext(“local[2]”) global offensives offensives=sc.accumulator(0) global total total = sc.accumulator(0) # Create Spark session def get_spark_session(): return SparkSession \ .builder \ .master(master) \ .appName(appName) \ .getOrCreate() def classify(utterance): # global offensives # global total try: classifier.classify(utterance) total += 1 except…

Details