✅ Easy to understand  | Beats 100% ✅
Intuition

We can iterate through each word in the list and check if the prefix matches the beginning of the word.


The Python string method .startswith() is e
# Intuition
- We can **iterate** through each word in the list and check if the prefix matches the beginning of the word.

- The Python string method **.startswith()** is efficient for this purpose.

# Approach
1. Initialize a ***counter*** to 0.
2. Iterate through each word in the words list.
3. For each word, check if it starts with the given pref. In Python, we can use the *startswith()* method for this.
4. If the word starts with the prefix, increment the counter.
5. After iterating through all words, return the counter.

# Complexity
- Time complexity:
Checking if a word starts with a prefix using .startswith() is O(m), where 𝑚 is the length of the prefix.
For a list of 𝑛 words, each of average length 𝑘, the total complexity is:

        O(n⋅m)

- Space complexity:
The solution does not use any additional data structures, and the space used is constant, O(1), apart from the input.

# Code
```python []
class Solution(object):
    def prefixCount(self, words, pref):
        count = 0
        for word in words:
            if word.startswith(pref):
                count += 1
        
        return count
```
['Python']