Python Intermediate Letter Counter Project Different Solution | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Python Intermediate Letter Counter Project Different Solution

Hello, I just finished the letter counter project in Python Intermediate and while I did complete the project successfully when looking at the other answers posted on threads I realized that they differed a lot from mine so I was wondering if there's anything fundamentally wrong with my solution. My Solution: text = input() dict = {} #your code goes here for i in text: sum=0 for a in text: if a==i: sum+=1 else: sum+=0 dict[i]=sum print(dict)

31st Mar 2021, 6:45 AM
Constantinos Romantzis
Constantinos Romantzis - avatar
2 Answers
+ 7
No your solution is correct ✅
31st Mar 2021, 7:01 AM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
+ 3
Your code is correct but: * It comprises of two loops even when this can be done using one loop. So always try to code using minimum loops. Because, more loops = more time consuming (for bigger inputs)
21st May 2021, 5:48 AM
Rahul kamat
Rahul kamat - avatar