Question 3:

Write a Python function to find the longest word that contains the highest occurrence of the letter 'a' in a given list.

Then, call this function with the following list as an argument:
```python
['Elena', 'Hamza', 'Tamarah', 'Halah', 'Amanda', 'Ahmad']
```



Answer :

Certainly! Let's break down the approach to solve this problem step-by-step:

1. Identify the Words List: We are provided with a list of words: `['Elena', 'Hamza', 'Tamarah', 'Halah', 'Amanda', 'Ahmad']`.

2. Count the Occurrences of 'a': For each word in the list, we need to count how many times the letter 'a' appears.

3. Find the Word with the Highest Occurrence of 'a': We need to compare the counts of 'a' in each word to find the one with the highest.

4. Handle Ties by Word Length: If multiple words have the same highest number of 'a's, we select the longest word amongst them.

Let's describe how this can be achieved in detail:

### Step-by-Step Solution:

1. Count 'a' in Each Word:
- Let's go through each word in the list and count the occurrences of 'a'.
- For "Elena", the count of 'a' is 0.
- For "Hamza", the count of 'a' is 2.
- For "Tamarah", the count of 'a' is 3.
- For "Halah", the count of 'a' is 2.
- For "Amanda", the count of 'a' is 3.
- For "Ahmad", the count of 'a' is 2.

2. Compare Occurrences and Length:
- Identify the words with the highest count of 'a'.
- "Tamarah" and "Amanda" both have 3 occurrences of 'a'.
- Between "Tamarah" (7 characters) and "Amanda" (6 characters), "Tamarah" is longer.

3. Choose the Longest Word with Highest 'a':
- Since "Tamarah" has the highest number of 'a' occurrences (3) and is the longest among those with the highest count, it is the word we are looking for.

### Final Result:
The word "Tamarah" contains the highest occurrence of the letter 'a' (3 times) and is the longest word with the highest count among the given list of words.

Hence, the function will return:
- The word: Tamarah
- The highest count of 'a': 3

So, the final answer is:
```
('Tamarah', 3)
```

This is the word with the highest occurrences of the letter 'a' and the longest in case of ties.