alphabet = 'abcdefghijklmnopqrstuvwxyz'
test_miss = ["aaa", "abcdddefrr"]
test_dups = ["aabbcc", "abcdd"]
def histogram(s):
hist = []
for i in alphabet:
if not((i in s) or (i.upper() in s)):
hist.append(i)
return hist
def has_dups(ss):
t = set()
test = True
for i in ss: t.add(i)
for i in t:
if ss.count(i)>1:
test = False
print(f"There are (is) {ss.count(i)-1} duplicate(s) of {i}")
if test:
print("There are not duplicates in this string")
def missing_letters(foo):
ans = histogram(foo)
ans.sort()
ans = ''.join(ans)
if len(ans)==0:
print("It uses all the letters")
else:
print(ans)
for i in test_dups:
print("###Calling the function test_dups###")
has_dups(i)
print()
for i in test_miss:
print("###Calling the function test_miss###")
missing_letters(i)
print()
Comments
Leave a comment