I may assume that the loop is not an infinite indeed, but I get the error that blocks me from moving to the next exercise: "The program took too long to finish. Check your code for infinite loops and try again."

I expect the loop to be stopped by logically reaching the False condition in While during the game and also I have "break" inside it.

alphabet = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, 
         "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, 
         "l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, 
         "r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, 
         "x": 8, "z": 10}
def scrabble_score(word):
    print "let's start SCRABBLE (enter 'stop' whenever you want to exit the game)"
    while available_score_points>0:
        for key in alphabet:
            if alphabet[key]>0:
                print "|%s-%s|" % (key, alphabet[key]),
        print "there are still", available_score_points, "available score points left"
        word=raw_input("spell the next word and get your score:")
        if len(word)==0:
            print "your word is empty, try again"
        elif word=="stop":
            print "thanks for playing, you scored:", score
            for letter in word:
                for key in alphabet:
                    if letter==key and alphabet[key]==0:
                        print "you can't use letters that are gone - try another combo"
                    elif letter==key and alphabet[key]>0:
        print "good job, your score is:", score
        print "let's go on"
        print "there are no available score points left"
        print "thanks for playing, you scored:", score


"Nice".. No response..


Do you ever return a score? If you do, I am missing it.


Sorry if "score" is ambiguous, since the dictionary in the original problem is named "score." But to clarify, I meant that a total number of points needs to be returned.


Yes, I missed "return score", but now I can't get back to the exercise, I waited too long for advice so I just rewrote the program in an easier way and it passed. However the original program works correctly in PyCharm.


Yes your code is perfectly valid, however, did not satisfy the requirements of the exercise, which is why you were not able to move on to the next exercise. Printing allows you to see the results of your code, but is not a substitute for returning a value, if that is what is required.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.