Python Forum
Dictionary comprehension
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionary comprehension
#1
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.
Reply
#2
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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020