anonymous
  • anonymous
I'm I loosing it? I'm on Prob Set 4.1 and I believe the solution is quite straighforward, but I am confused on something on the result I'm getting.
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
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.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
my code is : def get_word_score(word, n): score = 0 if len(word) == n: score += 50 for letter in word: print letter score += SCRABBLE_LETTER_VALUES[letter] print score
anonymous
  • anonymous
with get_word_score('waybill', 7) as my input, I get an output of: w 54 a 55 y 59 b 62 i 63 l 64 l 65 Shouldn't I just get the last score of 65 since the print statement is outside of the for loop? If I indent the print score statement to be on the same indentation as the print letter I get an unexpected indent error. I am confused!
anonymous
  • anonymous
I realized I posted the wrong code above. It should be: def get_word_score(word, n): score = 0 if len(word) == n: score += 50 for letter in word: print letter score += SCRABBLE_LETTER_VALUES[letter] print score

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Yes, but get_word_score needs to return the score, not print it.
anonymous
  • anonymous
Thanks for the reply! I know it's to return rather than print score, I just wanted to make sure it was the correct value. To solve my issue I had to manually retype the function for it to work. Very odd. Some voodoo going on :)
anonymous
  • anonymous
You might have had a tab issue. I've had a piece of code that looks correct, but I had to entirely retab it because somewhere a space was messing up the entire code.

Looking for something else?

Not the answer you are looking for? Search for more explanations.