how can I justify the output of this code?
N = int(input())
case = \'#\'
print(case)
for i in range(N):
case += \'#\'
print(case)
You can use format
with >
to right justify
N = 10
for i in range(1, N+1):
print('{:>10}'.format('#'*i))
Output
#
##
###
####
#####
######
#######
########
#########
##########
You can programattically figure out how far to right-justify using rjust
as well.
for i in range(1, N+1):
print(('#'*i).rjust(N))