Reputation: 185
try:
for v in d.values():
for item in v[1:]:
if item != v[0]:
except ValueError:
raise ValueError('this is inconsistent')
I am getting the following output-
except ValueError:
^ IndentationError: expected an indented block
Upvotes: 1
Views: 65
Reputation: 6545
The error may be because the program is expecting a statement after if item != v[0]:, but it finds none and is treating the except ValueError: line as the next line which is not at its right Indent.
Upvotes: 1
Reputation: 106430
If this is your entire code snippet, then after the line if item != v[0]:
, there isn't a statement. You would need to put one there.
If you would like to raise an exception instead, then you don't need the try...except
block around that piece of code. You would frame it as such:
for v in d.values():
for item in v[1:]:
if item != v[0]:
raise ValueError('this is inconsistent')
Upvotes: 5