How to check if a string in a list of strings has duplicate characters with Python

1 Answer

0 votes
def haseDuplicate(s):
     return len(s) != len(set(s))
     
lst = ["c", "python", "php", "java", "c++"] 

yes = False
for value in lst:
    if (haseDuplicate(value)):
        yes = True
        break
    
if (yes):
    print("yes")
else:
    print("no")
    
    
    

'''
run:

yes

'''

 



answered May 20, 2023 by avibootz
...