You are viewing a single comment's thread. Return to all comments →
For python2 it's better to use xrange (range for python3) and I think using rjust is more pythonic.
for i in xrange(1, n+1):
print ('#' * i).rjust(n)
I used string concatenation in my code's print statement, but I like this better! I'd never had cause to use rjust before, so it didn't even occur to me. This solution has the added bonus of actually following the problem description (i.e., "The staircase is right-aligned...").
Now I've learned something new. Cheers to you and nicolewhite and others who used rjust!