You're mixing old and new style string formatting here, and it won't work -- it'll just print "Course id conflict: explicit value %s does not match email value %s" every time. Please use {} for your string placeholders.