Exercise 9 – Writing values from a list into a file Complete thefunction design for the write_most_frequent() function, which takes4 parameters, a string, a list of tuples, an integer, and anotherstring: • The first string represents the name of the file to writeto (with the append usage mode) • The list of tuples contains theinformation to write. Assume the list has already been sorted. •The integer represents the number of elements to read from the listand write to the file • The title should be written to the filebefore writing data from the list.
def test_write_most_frequent():
  print(\"testing write_most_frequent\")
  list1 = [(\"a\",27), (\"bc\",25), (\"defg\",21), (\"hi\",21),(\"jk\",18),
        (\"l\",17),(\"m\",16), (\"nop\", 15), (\"qr\", 14), (\"s\", 13),
        (\"t\",10),(\"uv\",9), (\"x\",5), (\"yz\",2)]
  write_most_frequent(\"test_output.txt\", list1, 5,\"Alphabet Statistics\")
  # Should append to a file called test_output.txt thefollowing:
  # Results for Alphabet Statistics:
  # a: 27
  # bc: 25
  # defg: 21
  # hi: 21
  # jk: 18
  write_most_frequent(\"test_output.txt\", list1, 12,\"Large Alphabet Statistics\")
  # Should append to a file called test_output.txt thefollowing:
  # Results for Large Alphabet Statistics:
  # a: 27
  # bc: 25
  # defg: 21
  # hi: 21
  # jk: 18
  # l: 17
  # m: 16
  # nop: 15
  # qr: 14
  # s: 13
  # t: 10
  # uv: 9
-------------------------------------
# (str, (list of tuple), int, str -> None)
# appends to the file named filename data from the first
# n elements found in the given list; assumes the list issorted;
# the title given should be written on its own line first
def write_most_frequent(filename, list, n, title):
  print(\"Fix me\")