Letters counter | Sololearn: Learn to code for FREE!


Letters counter

Please help with the lesson 1 of the first chapter of intermediate phyton. I made this: text = input() dict = {} #tu código va aquí x=list(text) for i in range(len(x)): y=x.count(x[i]) dict[i]={x[i]:y} print(dict) Can someone explain me what is wrong??

5/24/2022 10:53:35 PM

Mabel Zavala Moreira

4 Answers

New Answer


Mabel Zavala Moreira , a bit late but I still want to share the code and some comments here. first file: help for your issue second file: description for a speed comparison using count() and othe methods for doinga character counter third file: sample code according the discription https://code.sololearn.com/cZ9t9oe3JV99/?ref=app https://code.sololearn.com/cxlMm6Jjj0zF/?ref=app https://code.sololearn.com/cMJUXDg4nb4u/?ref=app


Mabel Zavala Moreira I have attached a partial fix with comments below to assist you. There is one part of the puzzle to complete https://code.sololearn.com/c5zJLmZqpqjc/?ref=app


I am also finding ways to shorten it for t in text: dict[t] = text.count(t) print(dict)


# Good Luck dict[x[i]]=y #dict[i]={x[i]:y}