Write a grammar for the language consisting of strings that have n copies of the letter a followed by the same number of copies of the letter b and the the same number of copies of the letter c, where n >0. For example, the strings abc, aaaabbbbcccc, and aaaaaaaabbbbbbbbcccccccc are in the language but a, abbc, bac, and aaabbbcc are not

Respuesta :

Answer:

def language(mystring, n):

   if n > 0:

       string_list = [x for x in mystring]

       string_cont = ""

       for character in string_list:

           string_cont += character * n

       print(string_cont)

Explanation:

When n is equal to 0, that is, n=0, The python program multiplies the characters of the string "mystring" by the integer variable "n" to output a string with all characters with the same count.