Right Justify python -


how can justify output of code?

n = int(input()) case = '#' print(case)  in range(n):     case += '#'     print(case) 

you can use format > right justify

n = 10 in range(1, n+1):     print('{:>10}'.format('#'*i)) 

output

         #         ##        ###       ####      #####     ######    #######   ########  ######### ########## 

you can programattically figure out how far right-justify using rjust well.

for in range(1, n+1):     print(('#'*i).rjust(n)) 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -