-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathletter_histogram.py
61 lines (47 loc) · 1.28 KB
/
letter_histogram.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#User inputs a word and the dictionary collect and tally up how many times each letter in the alphabet was used in the word.
# user = input("banana".upper())
# def letter_count(letter, count):
# counter = 0
# for letter in user:
# counter += (letter == count)
# bank.append(bank[letter : count])
# return counter
# print(bank)
# print(bank[letter : count])
# for count in user:
# if user == alpha[count]:
# bank.append(alpha[user])
# counter = 0
# while counter < bank[counter]:
# word_count = bank[counter].value()
# counter += 1
# print(word_count)
# user = "banana"
# bank = []
# for user in alpha:
# wordcount = user.count(alpha)
# print(wordcount)
# for letter in user:
# bank.append(letter)
# count = 0
# while count < user.count(letter):
# double = letter + letter
# count += 1
# print(bank, end="")
# # for repeat in user:
# # if
#
########## - FINAL
word = input("Input a word and it will count the letters in the word: ").upper()
bank = []
counter = {}
num = []
for letter in word:
if letter not in bank:
bank.append(letter)
for index in bank:
num.append(word.count(index))
for i in range(len(bank)):
counter[bank[i]] = num[i]
print(counter)
print()