Essentially i have to write a program that counts how many time each letter occurs in a string. I got that working but letters duplicate, for example. If the string was hello it would output:
- h 1
- e 1
- l 2
- l 2
- o 1
When i need it to output:
- h 1
- e 1
- l 2
- o 1
The way i've done it so far is without importing anything and my code looks like:
input_text = input('Enter some text: ')
s = input_text.lower()
length_s = len(s)
l = 0
while length_s > 0:
if s[l].isalpha():
print(s[l], s.count(s[l]))
l += 1
length_s -=1
else:
l += 1
length_s -=1