vendredi 10 avril 2020

Remove extra space from pattern

This is a pattern for 180 degree triangle pattern in python

for i in range(0,n):
        for j in range(n,-1,-1):
            if(j<=i):
                    print("#",end="")
            else:
                    print(" ",end="")
        print("")

with this output is coming like this:

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

As you can see it has extra spaces What I want is:

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

Aucun commentaire:

Enregistrer un commentaire