input: Write a python function to find the longest common substring between two strings.
  assert longest_common_substring("abcdef", "zabcf") == "abc"
  assert longest_common_substring("hello", "ell") == "ell"
  assert longest_common_substring("python", "pyt") == "pyt"
output: def longest_common_substring(str1, str2):
      m = len(str1)
      n = len(str2)
      max_len = 0
      ending_index = m
  
      length = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
  
      for i in range(m + 1):
          for j in range(n + 1):
              if i == 0 or j == 0:
                  length[i][j] = 0
              elif str1[i - 1] == str2[j - 1]:
                  length[i][j] = length[i - 1][j - 1] + 1
                  if length[i][j] > max_len:
                      max_len = length[i][j]
                      ending_index = i
              else:
                  length[i][j] = 0
  
      return str1[ending_index - max_len: ending_index]