- 1

[Unsolved] Hello, I need fast help, I don't know what did I wrong 🙏, feel free to send full answers (Python)

https://code.sololearn.com/c2O5In0pk7QK/?ref=app

1st Dec 2021, 12:10 PM
Quarkom
8 Respostas
+ 7
Quarkom , i am quite sure that you are talking about python intermediate tutorial, lessen 10 project 'Letter Counter' it can be done like: ( not a full answer, but i am sure you can solve the task by yourself) (letter is a dictionary that has to be declared in advance, char is a variable that will get characters coming from the input string by using a for loop) â–Șuse a for loop to iterate over the input string â–Șif the current char is in dictionary letters: use this to "update" the current key/ value pair: letters[char] = letters[char] + 1 â–Șif the current char is NOT in dictionary letters: use this to create A NEW key / value pair: letters[char] = 1 after the loop is finished output the dictionary letters
1st Dec 2021, 3:22 PM
Lothar
Lothar - avatar
+ 5
Why does the help need to be fast? I'm not sure what you want to do but mind that while keys in a dictionary are unique, values don't need to be. Why not just print the whole dictionary? Or print("a:", D.get("a"))? Here's an overview of dictionary methods: https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_ref_dictionary.asp
1st Dec 2021, 12:41 PM
Lisa
Lisa - avatar
+ 2
print(D) works the way you described how you would expect the ouput should be, cause you already have the values with the get method inside the D value
2nd Dec 2021, 10:31 AM
TrnClli
TrnClli - avatar
+ 1
print([*D][0],':',D.get("a")) #this fits there.
1st Dec 2021, 1:39 PM
Jayakrishna 🇼🇳
0
I'd be grateful for any help 🙏
1st Dec 2021, 12:16 PM
Quarkom
0
Lisa it's just a pre code that should help me with whole project
1st Dec 2021, 1:56 PM
Quarkom
0
Lisa whole code should count how many specific letters are in inputted word, like: hello Output: {'h': 1, 'e': 1, 'l': 2, 'o': 1}
1st Dec 2021, 1:58 PM
Quarkom
0
Okey thank you
1st Dec 2021, 8:56 PM
Quarkom