he66666
  • he66666
can someone please help me find the error here? def get_letter_counts(dictionary): '''(dict of {str : list of strs}) -> dict of {str : int} Return a new dictionary with each key a single lowercase letter and each value the number of lowercase words that start with that letter.''' occurrence = {} for (letter, words) in dic.items(): occurrence[letter] = occurrence.get(letter, 0) + 1 occurrence[letter] = int(occurrence[letter]) return occurrence
Computer Science
  • 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.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
he66666
  • he66666
Btw, in the given dictionary, the key is a single lowercase letter and the value is a list of lowercase word starting with the certain letter.
he66666
  • he66666
The function doesn't seem to recognize multiple values so I always end up with only one value and the dictionary itself isn't ordered as well.
asnaseer
  • asnaseer
1) the parameter passed into this function is named 'dictionary', but the loop refers to 'dic' 2) make sure your indentation is correct (a common mistake is to mix tabs and spaces) 3) the code could be simplified by changing the for loop to: for (letter, words) in dic.items(): occurrence[letter] = len(words)

Looking for something else?

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

More answers

he66666
  • he66666
I intentionally changed the parameter to "dictionary" from "dic" to ask this question. I changed the for loop to the one your mentioned but it doesn't work.. and all the indentation is correct as well..
rsmith6559
  • rsmith6559
Your second post basically answered your question. You need a loop to iterate through the keys, which you have, but each key is going to give you a list of strings that you'll need another loop to iterate through to get the keys for your new dictionary.
he66666
  • he66666
Alright, thanks guys :)

Looking for something else?

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