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
Post a Comment