Problem p04032 (python)

Fixed submission:
s = input()

flag = 0
for i in range(len(s)-2):
  if s[i] == s[i+1]:
    print("{0} {1}".format(i+1, i+2))
    flag = 1
    break
  elif s[i] == s[i+2]:
    print("{0} {1}".format(i+1, i+3))
    flag = 1
    break
if s[-1] == s[-2] and flag == 0:
  print("{0} {1}".format(len(s)-1, len(s)))
  flag = 1
    
if flag == 0:
  print("{0} {1}".format(-1, -1))

Buggy submission (verdict: Runtime Error):
import sys

def convert(num):
  out = ""
  if num == 0:
    out = "a"
  elif num == 1:
    out = "b"
  elif num == 2:
    out = "c"
  elif num == 3:
    out = "d"    
  elif num == 4:
    out = "e"    
  elif num == 5:
    out = "f"    
  elif num == 6:
    out = "g"
  elif num == 7:
    out = "h"
  elif num == 8:
    out = "i"    
  elif num == 9:
    out = "j"    
  elif num == 10:
    out = "k"    
  elif num == 11:
    out = "l"
  elif num == 12:
    out = "m"
  elif num == 13:
    out = "n"    
  elif num == 14:
    out = "o"    
  elif num == 15:
    out = "p"    
  elif num == 16:
    out = "q"
  elif num == 17:
    out = "r"
  elif num == 18:
    out = "s"    
  elif num == 19:
    out = "t"    
  elif num == 20:
    out = "u"    
  elif num == 21:
    out = "v"
  elif num == 22:
    out = "w"
  elif num == 23:
    out = "x"    
  elif num == 24:
    out = "y"    
  else:
    out = "z"
  return (out)
    
    
    

s = input()
L = []
L.append(s.count("a"))
L.append(s.count("b"))
L.append(s.count("c"))
L.append(s.count("d"))
L.append(s.count("e"))
L.append(s.count("f"))
L.append(s.count("g"))
L.append(s.count("h"))
L.append(s.count("i"))
L.append(s.count("j"))
L.append(s.count("k"))
L.append(s.count("l"))
L.append(s.count("m"))
L.append(s.count("n"))
L.append(s.count("o"))
L.append(s.count("p"))
L.append(s.count("q"))
L.append(s.count("r"))
L.append(s.count("s"))
L.append(s.count("t"))
L.append(s.count("u"))
L.append(s.count("v"))
L.append(s.count("w"))
L.append(s.count("x"))
L.append(s.count("y"))
L.append(s.count("z"))

flag = 0
maxlist = []
for i in range(26):
  if L[i] == max(L):
    maxlist.append(i)
for j in range(len(maxlist)):
  for i in range(len(s)):
    if s[i] == convert(maxlist[j]):
      if s[i+1] == convert(maxlist[j]):
        print("{0} {1}".format(i+1, i+2))
        flag = 1
        break
      if s[i+2] == convert(maxlist[j]):
        print("{0} {1}".format(i+1, i+3))
        flag = 1
        break

if flag == 0:
  print("{0} {1}".format(-1,-1))

Buggy submission (verdict: Runtime Error):
import sys

def convert(num):
  out = ""
  if num == 0:
    out = "a"
  elif num == 1:
    out = "b"
  elif num == 2:
    out = "c"
  elif num == 3:
    out = "d"    
  elif num == 4:
    out = "e"    
  elif num == 5:
    out = "f"    
  elif num == 6:
    out = "g"
  elif num == 7:
    out = "h"
  elif num == 8:
    out = "i"    
  elif num == 9:
    out = "j"    
  elif num == 10:
    out = "k"    
  elif num == 11:
    out = "l"
  elif num == 12:
    out = "m"
  elif num == 13:
    out = "n"    
  elif num == 14:
    out = "o"    
  elif num == 15:
    out = "p"    
  elif num == 16:
    out = "q"
  elif num == 17:
    out = "r"
  elif num == 18:
    out = "s"    
  elif num == 19:
    out = "t"    
  elif num == 20:
    out = "u"    
  elif num == 21:
    out = "v"
  elif num == 22:
    out = "w"
  elif num == 23:
    out = "x"    
  elif num == 24:
    out = "y"    
  else:
    out = "z"
  return (out)
    
    
    

s = input()
L = []
L.append(s.count("a"))
L.append(s.count("b"))
L.append(s.count("c"))
L.append(s.count("d"))
L.append(s.count("e"))
L.append(s.count("f"))
L.append(s.count("g"))
L.append(s.count("h"))
L.append(s.count("i"))
L.append(s.count("j"))
L.append(s.count("k"))
L.append(s.count("l"))
L.append(s.count("m"))
L.append(s.count("n"))
L.append(s.count("o"))
L.append(s.count("p"))
L.append(s.count("q"))
L.append(s.count("r"))
L.append(s.count("s"))
L.append(s.count("t"))
L.append(s.count("u"))
L.append(s.count("v"))
L.append(s.count("w"))
L.append(s.count("x"))
L.append(s.count("y"))
L.append(s.count("z"))

flag = 0
for i in range(26):
  if L[i] == max(L):
    maxnum = i
    break
for i in range(len(s)):
  if s[i] == convert(maxnum):
    if s[i+1] == convert(maxnum):
      print("{0} {1}".format(i+1, i+2))
      flag = 1
      break
    if s[i+2] == convert(maxnum):
      print("{0} {1}".format(i+1, i+3))
      flag = 1
      break

if flag == 0:
  print("{0} {1}".format(-1,-1))