Quote:
Originally Posted by beckywc
Trying to add Reading but keep getting an error after else. This is what I have thus far:
Code:
def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str,
is_not_read_str, no_page_read_str, is_reading_str):
try:
test_val = int(is_read_pct)
except:
return 'is_read_pct is not a number'
import re
mg = re.match('.*last page read: location \d+ \((\d+)%\)', val, re.I + re.DOTALL);
if mg is None:
return no_page_read_str
try:
f = int(mg.group(1))
if f >= test_val:
return is_read_str
elif f > 0:
return is_reading_str
else:
return is_not_read_str
except:
pass
return no_page_read_str
I know it is something I'm doing wrong your help would be greatly appreciated.
|
Use the source from the above code block. I fixed the indents on the else and the return.
When doing python functions, spacing and indenting is critical. You must get it exactly right. Copying and pasting code from other than code blocks is almost certain to get it wrong.