use tag as an argument to call the iterator method next, substitute the result for invalid_tag. raise an CommandError exception with an argument string 'There is no system check with the "%s" tag.', where '%s' is replaced with invalid_tag.
raise CommandError ( 'There is no system check with the "%s" tag.' % invalid_tag )