Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 10 Online
OpenStudy (anonymous):

Two things with dictionaries: first, how do you call the value of a key? as in, for instance, when you want to assert that a value is greater something (my home made version: http://dpaste.com/768575/ ) Second, what's the logic behind creating a dictionary, i.e assigning values to a (potentially unknown) sequence? e.g. http://dpaste.com/768576/ thanks!

OpenStudy (anonymous):

ok, i found the get_value function. another question: why do i get nameerror for wordlist "not defined"? I mean, it's defined already in the helper code? http://dpaste.com/768652/ (excuse me for pasting the whole code, i think the most relevant part is lines 25-40 where the function load words is defined.) thanks!

OpenStudy (anonymous):

I don't think there's anything that defined as wordlist. In your main function, you call it word_list, and in get_word_score(), you refer to wordlist, but it's not defined. I don't think word_list would work either since word_list is not a global variable. You should either do your asserting in the main function, or feed the word_list in as an argument to that function. While we're at it, on line 88-89, you have a for loop that assigns to the variable "letter" a range of indices. However, SCRABBLE_LETTER_VALUES is a dictionary and does not take indices, it takes keys and returns their values. I think the for loop should just say "for letter in word." Then it will feed *characters* into the dictionary lookup, not numbers.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!