Hi, In ps5 problem 2 when I run update_hand manually it returns the right answer but when I run the test it returns none. Any idea why this happens? Here is my code for update_hand: for i in range (0, len(word)): used = word[i] if hand[used] >= 0: hand[used] = hand[used] - 1 return hand

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

Hi, In ps5 problem 2 when I run update_hand manually it returns the right answer but when I run the test it returns none. Any idea why this happens? Here is my code for update_hand: for i in range (0, len(word)): used = word[i] if hand[used] >= 0: hand[used] = hand[used] - 1 return hand

MIT 6.00 Intro Computer Science (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

1) you probably want to use codepad.org to create links to your code 2) I can't tell why without the code for 'test'
The code for test_update_hand, http://codepad.org/hPApKb1R
could you please explain to me how you are able to access the words.txt file. When I use WORDLIST_FILENAME = open ("words.txt") I get the following error code inFile = open(WORDLIST_FILENAME, 'r', 0) TypeError: coercing to Unicode: need string or buffer, file found

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

It should be WORDLIST_FILENAME = "words.txt" The error you're getting is because you have open("words.txt").
what are you trying to accomplish here? expected_hand2 = {'a':0, 'q':0, 'l':1, 'm':1, 'u':0, 'i':0} if hand2 != expected_hand1 and hand2 != expected_hand2: here's what I think is happening. your program works. hand2 is updated correctly. hand2 = {'a':0, 'q':0, 'l':1, 'm':1, 'u':0, 'i':0} then you have IF NOT EQUAL but hand2 and expected_hand2 are equal, so your if statement doesn't run.
by here, I mean these 2 lines of codes expected_hand2 = {'a':0, 'q':0, 'l':1, 'm':1, 'u':0, 'i':0} if hand2 != expected_hand1 and hand2 != expected_hand2:
looks like it works to me http://codepad.org/JJGkZKMJ
check to see what the values for the letters are before you start, then either keep it in the dictonary or delete it. for letter in word: numberofletters=hand.get(letter,0) if numberofletters==0: return word,'cannot be spelled from this hand' if numberofletters==1: del hand[letter] if numberofletters>1: hand[letter]=hand[letter]-1 return hand

Not the answer you are looking for?

Search for more explanations.

Ask your own question