Answer to Question #196631 in Python for FORTUNE AIDOO

Question #196631

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. 

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.  

QUESTIONS NOT COMPLETE BUT IT WILL BE CONTINUE.....

1
Expert's answer
2021-05-23T08:49:25-0400
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


def has_duplicates(s):
    for value in histogram(s).values():
        if value > 1:
            return True
    return False

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS