Python Intermediate Letter Counter Project Different Solution | Sololearn: Learn to code for FREE!

+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)

3/31/2021 6:45:03 AM

Constantinos Romantzis

2 Answers

New Answer

+7

No your solution is correct ✅

+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)