-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path19.py
27 lines (24 loc) · 777 Bytes
/
19.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def freq(s2):
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
l = []
ans = []
l2 = []
#creates list full of 0s that will count the frequency of each letter
for i in range(25):
l.append(0)
#finds letter in s, uses that letter to find index in alpha, counts that index in l up by 1
#therefore counting the letter index
for i in s:
if i != ' ':
l[alpha.index(i)] = l[alpha.index(i)] + 1
for i in range(len(l)):
if l[i] != 0:
ans.append(alpha[i])
l2.append(i)
#print(ans)
#print(l2)
for i in range(len(ans)):
x = l2[i]
print(ans[i] + ":" + str(l[x]))
s = input('Enter word:')
freq(s)