Determine if a string has all Unique Characters | Python program to illustrate string with unique characters using brute force technique ; If at any time we encounter 2 same characters , return false ; If no duplicate characters encountered , return true ; Driver Code
def uniqueCharacters ( str ) : NEW_LINE INDENT for i in range ( len ( str ) ) : NEW_LINE INDENT for j in range ( i + 1 , len ( str ) ) : NEW_LINE INDENT if ( str [ i ] == str [ j ] ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT DEDENT return True ; NEW_LINE DEDENT str = " GeeksforGeeks " ; NEW_LINE if ( uniqueCharacters ( str ) ) : NEW_LINE INDENT print ( " The ▁ String ▁ " , str , " ▁ has ▁ all ▁ unique ▁ characters " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " The ▁ String ▁ " , str , " ▁ has ▁ duplicate ▁ characters " ) ; NEW_LINE DEDENT