Assignment Anywhere Makes It Local

total = 100

def report(flag):
    print(total)
    if flag:
        total = 5
    return total

report(False)

flag is False, so the line total = 5 never executes. It looks like print(total) should simply print the module-level value 100. Instead, calling report(False) raises an exception before anything prints. Name the exact exception class (e.g. TypeError).