0
Letter counter (dictionary output)
text = input() dict1 = {} #your code goes here letters1 = [] count1 = [] for i in text: if i not in letters1: letters1.append(i) else: continue for k in letters1: if k==" ": continue else: count1.append(text.count(k)) for l in range(len(letters1)): dict1[letters1[l]]=count1[l] print(dict1) #Hello everyone, i wrote this and it's working. But how can it be more short ?
3 Respostas
0
Btw the task is "Creating a program to take a string as input and output a dictionary, which represents the letter count." Example ;
İnput : hello
Output : {'h':1, 'e':1, 'l':2, 'o': 1}
0
Hahaha thanks 😂