Problem p02629 (python)

Fixed submission:
def alf(st):
  if st == 0:
    return "a"
  if st == 1:
    return "b"
  if st == 2:
    return "c"
  if st == 3:
    return "d"
  if st == 4:
    return "e"
  if st == 5:
    return "f"
  if st == 6:
    return "g"
  if st == 7:
    return "h"
  if st == 8:
    return "i"
  if st == 9:
    return "j"
  if st == 10:
    return "k"
  if st == 11:
    return "l"
  if st == 12:
    return "m"
  if st == 13:
    return "n"
  if st == 14:
    return "o"
  if st == 15:
    return "p"
  if st == 16:
    return "q"
  if st == 17:
    return "r"
  if st == 18:
    return "s"
  if st == 19:
    return "t"
  if st == 20:
    return "u"
  if st == 21:
    return "v"
  if st == 22:
    return "w"
  if st == 23:
    return "x"
  if st == 24:
    return "y"
  if st == 25:
    return "z"
   
def cc():
  N,=list(map(int, input().split()))
  li = [0 for i in range(100)]
  NN = N
  count=1
  for i in range(1,100):
    if NN > 26 ** i:
      NN = NN - 26 ** i
    else:
      l=i
      break; 
  NN-=1
  count=0
  while True:
    li[count]=NN%26
    count+=1
    NN //=26
    if NN <26:
      li[count]=NN%26
      break    
  re=[alf(i) for i in li[:l]]
  re.reverse()
  print("".join(re))

cc()

Buggy submission (verdict: Runtime Error):
def alf(st):
  if st == 1:
    return "a"
  if st == 2:
    return "b"
  if st == 3:
    return "c"
  if st == 4:
    return "d"
  if st == 5:
    return "e"
  if st == 6:
    return "f"
  if st == 7:
    return "g"
  if st == 8:
    return "h"
  if st == 9:
    return "i"
  if st == 10:
    return "j"
  if st == 11:
    return "k"
  if st == 12:
    return "l"
  if st == 13:
    return "m"
  if st == 14:
    return "n"
  if st == 15:
    return "o"
  if st == 16:
    return "p"
  if st == 17:
    return "q"
  if st == 18:
    return "r"
  if st == 19:
    return "s"
  if st == 20:
    return "t"
  if st == 21:
    return "u"
  if st == 22:
    return "v"
  if st == 23:
    return "w"
  if st == 24:
    return "x"
  if st == 25:
    return "y"
  if st == 0:
    return "z"
   
N,=list(map(int, input().split()))
li = []
NN = N
count=1
while True:
  li+=[NN%26]
  NN = NN//26
  if NN <26:
    if NN%26!=0:
      li.append(NN%26)
    break
  count+=1
  if count>1000000000000001:
    print("error")
    exit()
#print(li)
for i in range(len(li)-1):
  if li[i]== 0:
    li[i+1]-=1
#print(li)
if(li[len(li)-1])==0:
  li.pop() 
re=[alf(i) for i in li]
re.reverse()
print("".join(re))

Buggy submission (verdict: Runtime Error):
def alf(st):
  if st == 1:
    return "a"
  if st == 2:
    return "b"
  if st == 3:
    return "c"
  if st == 4:
    return "d"
  if st == 5:
    return "e"
  if st == 6:
    return "f"
  if st == 7:
    return "g"
  if st == 8:
    return "h"
  if st == 9:
    return "i"
  if st == 10:
    return "j"
  if st == 11:
    return "k"
  if st == 12:
    return "l"
  if st == 13:
    return "m"
  if st == 14:
    return "n"
  if st == 15:
    return "o"
  if st == 16:
    return "p"
  if st == 17:
    return "q"
  if st == 18:
    return "r"
  if st == 19:
    return "s"
  if st == 20:
    return "t"
  if st == 21:
    return "u"
  if st == 22:
    return "v"
  if st == 23:
    return "w"
  if st == 24:
    return "x"
  if st == 25:
    return "y"
  if st == 26:
    return "z"
   
N,=list(map(int, input().split()))
li = []
NN = N
count=1
while True:
  li+=[NN%26]
  NN = NN//26
  if NN <26:
    if NN%26!=0:
      li.append(NN%26)
    break
  count+=1
  if count>1000000000000001:
    print("error")
    exit()
re=[alf(i) for i in li]
re.reverse()
print("".join(re))