wikipediagame: show correct percentage with wrong guess - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit b88a487b93a248efa8a8c0079b328192de563607 DIR parent c8452078103bd14dfbaa10f0254d8337b43aa004 HTML Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Tue, 11 Apr 2023 21:31:10 +0200 wikipediagame: show correct percentage with wrong guess Signed-off-by: Annna Robert-Houdin <annna@bitreich.org> Diffstat: M wikipediagame | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- DIR diff --git a/wikipediagame b/wikipediagame @@ -9,6 +9,7 @@ import sys import getopt import wikipedia as w import json +from difflib import SequenceMatcher def usage(app): app = os.path.basename(app) @@ -110,7 +111,8 @@ def main(args): if os.path.exists(titlepath): os.remove(titlepath) else: - print("Sorry, wrong guess.") + print("Sorry, wrong guess. (%.0f%% correct)" % \ + (SequenceMatcher(None, title.strip().lower(), trytext.strip().lower()).ratio() * 100)) return 0