How to check if string has duplicate characters in Python

1 Answer

0 votes
def haseDuplicate(s):
     return len(s) != len(set(s))


s1 = "python java c"
print(haseDuplicate(s1))

s2 = "python c"
print(haseDuplicate(s2))



'''
run:

True
False

'''

 



answered May 20, 2023 by avibootz
...