Get reliable answers to your questions at Westonci.ca, where our knowledgeable community is always ready to help. Our Q&A platform provides quick and trustworthy answers to your questions from experienced professionals in different areas of expertise. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.

Start with the following Python code.
alphabet = "abcdefghijklmnopqrstuvwxyz"
test_dups = ["zzz","dog","bookkeeper","subdermatoglyphic","subdermatoglyphics"]
test_miss = ["zzz","subdermatoglyphic","the quick brown fox jumps over the lazy dog"]
def histogram(s):
d = dict()
for c in s:
if c not in d:
d[c] = 1
else:
d[c] += 1
return d

Copy the code above into your program but write all the other code for this assignment yourself. Do not copy any code from another source.

Write a function called has_duplicates that takes a string parameter and returns True if the string has any repeated characters. Otherwise, it should return False.

Implement has_duplicates by creating a histogram using the histogram function above. Your implementation should use the counts in the histogram to decide if there are any duplicates.

Write a loop over the strings in the provided test_dups list. Print each string in the list and whether or not it has any duplicates based on the return value of has_duplicates for that string. For example, the output for "aaa" and "abc" would be the following.

aaa has duplicates
abc has no duplicates

Print a line like one of the above for each of the strings in test_dups.


Sagot :

Answer:

huwugsgssuaihsux h baiThatha svaadishht us

Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.