In [12]:
from itertools import count
s = 0
for base in range(1, 10):
for exp in count(1):
if len(str(base**exp)) == exp:
s += 1
print(base, exp, base**exp)
else: break
print(s)
In [ ]: