+ 1

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??

24th May 2022, 10:53 PM
Mabel Zavala Moreira
4 ответов
+ 5
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
25th May 2022, 4:51 PM
Lothar
Lothar - avatar
+ 3
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
25th May 2022, 1:49 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
I am also finding ways to shorten it for t in text: dict[t] = text.count(t) print(dict)
25th May 2022, 2:52 AM
SoloProg
SoloProg - avatar
+ 1
# Good Luck dict[x[i]]=y #dict[i]={x[i]:y}
24th May 2022, 11:44 PM
SoloProg
SoloProg - avatar