Answer to Question #125697 in Python for Desimio Papatakorn

Question #125697
write a function norep(x:str)->bool:
if the characters appear twice, it should return False, and character length should be at least 6.
1
Expert's answer
2020-07-09T11:14:56-0400
def norep(x):
    splitted = x.split()
    if len(splitted) > 1:  # words count
        for w in set(splitted):
            if splitted.count(w) == 2 and len(w) >= 6:
                return False
        else:
            return True
    else:  # symbols count
        splitted = list(x)
        for s in set(splitted):
            if splitted.count(s) == 2 and len(splitted) >= 6:
                return False
        else:
            return True

str = 'example'
print(norep(str))

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