Reputation: 139
Python 2.7.10 (default, Jul 15 2017, 17:16:57) Pycharm 2017.3.3 Community build.
Newb question:
Is there a clean way to assign a group of exceptions to one variable, more than once, in an effort to give a two or more groups the same error?
a = 10
b = 0
try:
c=a/b
#except (ZeroDivisionError, TypeError) as a:
# raise Exception('The error was: %s’ %a)
except (NameError, MemoryError) as e:
raise Exception('There is an error. The error is %s' %e)
When I uncomment the first exception I get:
File "<input>", line 8
raise Exception('The error was: %s’ %a)
^
SyntaxError: EOL while scanning string literal
--Please forgive me if it's my syntax, but I just don't see it and this is a brand new language for me. Thank you
Upvotes: 0
Views: 67
Reputation: 6748
Here is your error: raise Exception('The error was: %s’ %a)
. This line has smart quotes. The interpreter only recognises real quotes: raise Exception('The error was: %s' %a)
Upvotes: 2