def update_scores(score_file):
    """Gets the current scores from the score file, updates them and raises a
    congratulatory message if a level-up has occured.

    """
    root_folder, old_scores = read_score_file(score_file)
    old_levels = {lang: level(old_scores[lang]) for lang in old_scores}
    new_scores = get_scores(root_folder)
    new_levels = {lang: level(new_scores[lang]) for lang in new_scores}
    congrats = ""

    for lang in sorted(old_levels):
        try:
            if new_levels[lang] < old_levels[lang]:
                congrats += "".join(["You have advanced to level ",
                                     str(new_levels[lang]),
                                     " in ", lang, "!\n"])
        except KeyError:
            pass

    if congrats:
        congrats = "Congratulations!\n\n" + congrats
        root = Tk()
        window = LevelUpWindow(root, message=congrats, button_text="Hooray!")
        root.mainloop()

    update_score_file(new_scores, score_file, head=os.path.abspath(root_folder))
dataset/ETHPy150Open the-xkcd-community/the-red-spider-project/src/level_up.py/update_scores/swapped operands of `<`