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

Assignment 5: Problem #3. I understand how to compare the word with word_list, but I'm struggling a little with comparing it with hand. What happens when a word has too many letters for a value in the dict ? (word=hello, while hand includes l:1 (instead of l:2)

OpenStudy (anonymous):

well, then you can't make that word with that hand. are you having trouble with the actual comparison? could you turn the word into a letter-frequency dictionary then compare the two dictionaries? or possibly use the count function with the word? ... i.e. 'hello'.count('l') returns 2.

OpenStudy (anonymous):

I'll try both ! :)

OpenStudy (anonymous):

I created a copy of the dictionary, for each letter in the WORD I took it out of the copy of the hand dictionary, then checked if the letter was less then zero (l:-1), i've attached my is valid word function if you want to take a look

OpenStudy (anonymous):

hey, if you could put your code on dpaste.com, it would be a lot more accessible so people can look at it

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!