0

Guys help me in this problem in python:Giving a input as 'hello' the output should be in dict as {'h':1,'e':1,'l':2,'o':1}

Dont use any built in functions

21st Nov 2018, 2:21 PM
Gowtham Nk
Gowtham Nk - avatar
2 Réponses
+ 5
Hi, I know it looks a little strange, but I hope it helps :) word = "hello" final={} for i in word: final[i] = 0 #sets the Key:Value pair in dictionary for c in word: final[c] += 1 #counts the letters in the word print(final) #output = {'h': 1, 'e': 1, 'l': 2, 'o': 1}
21st Nov 2018, 3:32 PM
Proff
Proff - avatar
+ 3
Please show your attempt first.
21st Nov 2018, 2:38 PM
Kishalaya Saha
Kishalaya Saha - avatar