This function takes in a string of letters separated by commas. You can # assume that the string s contains only english letters in lower-case & # separated arbitrarily by commas. # # This function examines each string fragment that are separated by commas. # If any of the fragments contains the same letter repeated exactly MAX_DIGIT # times it returns True. Otherwise, it returns False. #

Respuesta :

Answer:

Check the explanation

Explanation:

def has_triggers(string):

 

### split() splits the string using comma and store them in a list li

   li=string.split(",")

 

### iterate through the list and find the size of 5

   for i in range(len(li)):

     

## # if the length is > 0 and the all the 5 characters are same then returns true.

       if(len(li[i])>0 and li[i]==li[i][0]*5):

           return True

     

   return False

###calling function by passing the input string and prints the returned value

print(has_triggers('a,aaaa,aaaaa,a'))

print(has_triggers('ab,xxxxx,yxyx,m'))

print(has_triggers('ab,xx,xx,yxyx,n'))

print(has_triggers('ab,pppppppppp,qq'))

print(has_triggers(',abc,abc,abc,,,'))