PS4 - Playing a Hand: Hello, I have a annoying situation with my code, mine in Idle works fine, and my totalScore variable, does not accumulate in every test, and to make it more annoying grader says my output is this: Current Hand: a d i k o n Enter word, or a "." to indicate that you are finished: daikon "daikon" earned 116 points. Total: 116 points Current Hand: *** Error: Your code called raw_input more times than necessary. Please review where you are using the raw_input function. Additionally also be sure your print statements match up with the sample output. But my output on I

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.

PS4 - Playing a Hand: Hello, I have a annoying situation with my code, mine in Idle works fine, and my totalScore variable, does not accumulate in every test, and to make it more annoying grader says my output is this: Current Hand: a d i k o n Enter word, or a "." to indicate that you are finished: daikon "daikon" earned 116 points. Total: 116 points Current Hand: *** Error: Your code called raw_input more times than necessary. Please review where you are using the raw_input function. Additionally also be sure your print statements match up with the sample output. But my output on I

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

Bu my output on Idle is: playHand({'a': 1, 'd': 1, 'i': 1, 'k': 1, 'o': 1, 'n': 1}, wordList, 6) Current Hand: a d i k o n Enter word, or a "." to indicate that you are finished: daikon "daikon" earned 116 points. Total: 116 points Run out of letters. Total score: 116 points.
The grader shows that I make again this code line: word = (raw_input('Enter word, or a "." to indicate that you are finished: ').lower()) My Idle does not show it.
Should I include the other def I use on the code? I mean: isValidWord, getWordScore, updateHand. BTW I use a global variable totalScore, and totalScore = 0 is outside of def playHand(hand, wordList, n):

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

I had the same problem at first, along with a few others. Try taking out the doc string for starters...
What doc string? I don't understand. Btw I have a "totalEarned = 0" outside of the def playhand(....) and I use "global totalEarned" because when I call inside of playhand function to make it recursive "totalEarned" would be initialize to zero.
the doc string is the thing that is in quotes in red before your code on the edX site
Ow ok, in the grader is like this: totalEarned = 0 def playHand(hand, wordList, n): """ """ earned = 0 global totalEarned
yeah take out the '''' '''' stuff also you should really not need a global variable like that, especially for the edX grader which is not integrated into your IDLE
nothing should be before your definition on the grader though
I will just tell you that mine only has HAND_SIZE as defined before the code, yet it is still after the definition def playGame(wordList): i=0 n=HAND_SIZE the variable i I just used for the replay part, you can ignore that my point is that I really don't think you should have any global variables, or anything before def playGame
well actually I put it outside of the function. But when my code reach this section: earned = getWordScore(word,n) totalEarned += earned print '"'+word+'"' + ' earned', earned,'points. Total:' , totalEarned , 'points' print '' hand = updateHand(hand, word) return playHand(hand, wordList, n) I use return playHand(...) and that's when totalEarned becomes zero, if I initilize it (totalEarned = 0) inside of def playHand(...)
well mine is not recursive also I was confused, I thought we were looking at playGame, not playHand, but still, no global variables or assignments before the definition should be necessary. instead of a recursive call I used a while loop, I will show you my first couple assignments: def playHand(hand, wordList, n): n=calculateHandlen(hand) totalScore=0 while... so I needed no assignments before def playHand, nor global variables.
I started like that, I didn't like to deal that when I reach -inside of while loop- if is not a valid word ... what next? a while inside of a while, to keep asking for a valid word, and I didn't like it to do that.
But let me tell you, on Idle it works perfectly xD
Oh I believe you, the grader on this is picky, I had the same error message as you at first It worked with pseudocode something like #while the hand is not empty, continue #display hand, ask for raw input #if the word is the '.', break out of program # if the word is valid, get score etc. #if the word is not valid, tell the user so this way the program runs until there are either no more letters, or the user presses '.' no recursion necessary.
yeah I got you, I've never seen it so capricious, I'll make it again, and now using the pseudocode, the last time I erased it all xD thanks!
Yeah that easy xD just 3 minutes and just have to correct this: playHand({'a': 2, 'p': 1, 'r': 1, 'e': 2, 't': 1}, wordList, 7) pear = 24 points tea = 59 points (should be only 9 but I use the whole word) It's a bug?? I've never play scrabbel

Not the answer you are looking for?

Search for more explanations.

Ask your own question