Python Forum

Full Version: Dictionary comprehension
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!
I want to write a function ,def count_words_starting_with_given_letter(text, letter):, for example:
print(count_words_starting_with_given_letter('Tom has tiger ', 't') == {'Tom': 1, 'tiger': 1}).
I know how to write code, but I have to use dictionary comprehension and I am little confused.
Here's a forum link Thread-Comprehension-Expressions
If get stuck, post the specific part your stuck on with code in python code tags and any errors received in error tags.