Thats how print
works. It prints the string representation of its argument(s) followed by end
which is a newline by default. Thats why your output is not all on the same line to begin with.
You can manually specify end
like this:
for i in range(1,int(input())+1):
print(((10**i-1)//9)**2, end='')
but then everything will be on the same line. The workaround is to print the newlines separately.
for i in range(1,int(input())+1):
print()
print(((10**i-1)//9)**2, end='')
Here the newline is being printed before the string which prevents there being a trailing one. However there will be a leading newline instead. But that can be taken care of by not calling print()
on the first iteration of the loop.
for i in range(1,int(input())+1):
if i != 0:
print()
print(((10**i-1)//9)**2, end='')