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
2 Answers
+ 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}
+ 3
Please show your attempt first.