for j in range(1,i+1): ...
Some basic Python programmes solution of edx.org python exercises ...