I am writing a program for counting number of digits in a non negative integer whose upper bound is 10^{1000000} and has a time limit of 12 seconds I have declared an array with size 1000000 and the indexes 0,1,2...,1000000 correspond to the number of digits of the number represented by 10^{array index}. However I am getting Time Limit Exceeded for input ranges close to 10^{10000}. Please find inline the code for the same:
def Number(x):
a=[0]*(1000000)
for j in xrange(len(a)):
#print j
a[j]=j+1
i=0
flag=0
flagc=0
counter=0
while(i<len(a)-1):
#print x
if (10**i)==x:
print a[i]
flag=1
break
elif x>(10**i) and x<(10**(i+1)):
print a[i]
flag=1
break
i=i+1
if (i==len(a)-1 and flag==0 and x==(10**i)):
print a[i]
number=int(input())
Number(number+1)
Please help as to how to handle large input values for the above as time limit got exceeded is coming for inputs close to 10^10000