Take extra care for cases when A is divisible by 26 and yields a remainder of zero


#1
An example of a successful code in python
class Solution:
def convertToTitle(self, A):
    ans = []
    while(A>0):
        A, rem = divmod(A, 26)
        if rem>0:
            ans.append(chr(rem+64))
        if rem==0:
            ans.append('Z')
            A -= 1
    s = ''.join(ans)
    return s[::-1]