There are two things wrong here. First, You need parenthesis to enclose the errors:
except (ValueError,IOError) as err:
See a demonstration below:
>>> try:
... 1/0
... except Exception,Exception as e:
File "<stdin>", line 3
except Exception,Exception as e:
^
SyntaxError: invalid syntax
>>> try:
... 1/0
... except (Exception, Exception) as e:
... print e
...
integer division or modulo by zero
>>>
Second, you need a try to go with that except line:
def average():
try:
TOTAL_VALUE = 0
FILE = open("Numbers.txt", 'r')
for line in FILE:
AMOUNT = float(line)
TOTAL_VALUE += AMOUNT
NUMBERS_AVERAGE = TOTAL_VALUE / AMOUNT
print("the average of the numbers in 'Numbers.txt' is :",
format(NUMBERS_AVERAGE, '.2f'))
FILE.close()
except (ValueError,IOError) as err:
print(err)
except cannot be used without try.