We've integrated a python execution environment into the Playful Python site! Not only can you read code, you can now type it out and execute it, online, right here on the site 😎
In the previous articles covering the word count problem so far, we have tried a variety of approaches to write a function to count the number of times a word appears in a sentence. Now let us attempt the bonus part of it.
Where we look at two data structures - defaultdict and Counter - supplied in the python standard library
Python dicts have a get method. How could it help us?
In this article, we will look at the word count problem through the lens of two coding styles: Look before you leap (LBYL) vs Easier to Ask for Forgiveness than Permission (EAFP)
I really love this problem because there are so many things to explore and learn about Python here. In this, and the next few articles, we will explore some of the dimensions of this problem.
This might be one of the smallest, yet most beautiful features in Python: negative indexing. I'm still surprised why other languages haven't copied this feature because it such a simple feature, yet makes such a huge difference.