Write a loop over the strings in list test_miss and call missing_letters with each string. Print a line for each string listing the missing letters. For example, for the string "aaa", the output should be the following.
aaa is missing letters bcdefghijklmnopqrstuvwxyz
If the string has all the letters in alphabet, the output should say it uses all the letters. For example, the output for the string alphabet itself would be the following.
abcdefghijklmnopqrstuvwxyz uses all the letters
Print a line like one of the above for each of the strings in test_miss.
Submit your Python program. It should include the following.
Also submit the output from running your program.
letters = 'abcdefghijklmnopqrstuvwxyz'
test_miss = ["aaa", "abcdddefrr"]
test_dups = ["aabbcc", "abcdd"]
def histogram(s):
Hi = []
for x in letters:
if not((x in s) or (x.upper() in s)):
Hi.append(x)
return Hi
def has_dups(y):
m = set()
T = True
for x in y: m.add(x)
for x in m:
if y.count(x)>1:
T = False
print(f"There are {y.count(x)-1} duplicate of {x}")
if T:
print("There are not duplicates in this string")
def missing_letters(u):
answer = histogram(u)
answer.sort()
answer = ''.join(answer)
if len(answer)==0:
print("It uses all the letters")
else:
print(answer)
for x in test_dups:
has_dups(x)
print()
for x in test_miss:
missing_letters(x)
print()
Comments
Leave a comment