i have simple pyramid. works this: 1.you input number , a/or multiple characters 2.you receive print show number multiplied character. table displayed pyramid.
i thinking of getting len() of string , have no idea else aligned right.
problem : if 5 g g gg ggg gggg ggggg if 5 gg gg gggg gggggg gggggggg gggggggggg
my rjust doesn't seems trick this.
import sys def pyramide(nbr, char): resultat = '' in range(0, nbr+1): resultat += (nbr * str('') + int(i) * str(char) + "\n").rjust(nbr+1) return resultat def main(): nbr = int(sys.argv[1]) char = (sys.argv[2]) message = pyramide(nbr, char) print(message) if __name__ == "__main__": main()
i'd start adding prespacing, add in amount of characters:
def pyramide(size, char): resultat = '' in range(0, size): resultat += (' ' * (size-i)) + (char * int(i*2+1)) + '\n' return resultat
Comments
Post a Comment