Try the following:
print(j, end='')
end by default is \n (see print() ). Also, remember to print a new line at the end of each iteration of the outer loop:
for i in range(1,6): # notice that I changed this to 6 for j in range(1,i): print(j, end='') # added end='' print() # printing newline here
one
12
123
1234
EDIT I just noticed that you are using Python 2.7. In this case, you can use print j, instead of print(j, end='') and print instead of print() . Note that print j, will leave spaces between j s. If you do not want this, you can import sys and use sys.stdout.write(j) instead (see sys ).
Also, if you want to use the Python 3 print function as shown above, you can always
from __future__ import print_function
source share