human
Quick way to check if all the characters of a string are same | Function to check is all the characters in string are or not.
Insert characters in the set.
If all characters are same Size of set will always be 1.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to quick way to check if all the characters of a string are same and the other steps required.
 def allCharactersSame ( s ) :
	s1 = [ ]
	for i in range ( len ( s ) ) :
		s1 . append ( s [ i ] )
	s1 = list ( set ( s1 ) )
	if ( len ( s1 ) == 1 ) :
		print ( " YES " )
	else :
		print ( " NO " )
Str = " nnnn "
allCharactersSame ( Str )