# Data structure exercise

**URL:** <https://forum.codewithmosh.com/t/data-structure-exercise/8127>\
**Category:** Python\
**Created:** [October 24, 2021, 8:20pm UTC](https://forum.codewithmosh.com/t/data-structure-exercise/8127 "2021-10-24T20:20:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lt.Smith](https://avatars.discourse-cdn.com/v4/letter/l/3bc359/32.png) [@Lt.Smith](https://forum.codewithmosh.com/u/Lt.Smith)\
**Post date:** [October 24, 2021, 8:20pm UTC](https://forum.codewithmosh.com/t/data-structure-exercise/8127/1 "2021-10-24T20:20:17Z")

</div>

Hello! Has anyone resolved the exercise on their first try ? I had some basic idea on how to solve but apparently it was at most 10% of the entire exercise solution and the solution that Mosh provided left me starring at the monitor …

---

<div class="post-metadata">

**Author:** ![Salurex](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Salurex](https://forum.codewithmosh.com/u/Salurex)\
**Post date:** [September 13, 2022, 4:14pm UTC](https://forum.codewithmosh.com/t/data-structure-exercise/8127/2 "2022-09-13T16:14:29Z")

</div>

Hi.  
It took me 5 minutes. That is my first try. I am not sure if that is correct… However:

sentence = “This is a common interview question”  
winner = " "  
summary = 0  
for item in sentence.replace(" ", “”):  
number = sentence.count(item)  
if number \> summary:  
summary += number  
winner = item, number

print(winner)
