Append "0" P times
temp = " " NEW_LINE for i in range ( p ) : NEW_LINE INDENT temp += '0' NEW_LINE DEDENT st = " " NEW_LINE st += ans [ 0 ] NEW_LINE st += temp NEW_LINE for i in range ( 1 , len ( ans ) ) : NEW_LINE INDENT st += ans [ i ] NEW_LINE DEDENT ans = st NEW_LINE