mardi 16 août 2016

Kind of pyramid numbers pattern exercise

didn't found this one exactly. Can you help to simplify the code and make it more efficient? Mine seems like it's not the best version, what can I improve?

     1
    232
   34543
  4567654
 567898765
678901109876

This is the code I made:

c = -1

for y in range(1, 7):
    print()
    print((6-y) * " ", end="")
    c += 1

for x in range(1, y+1):
    print(y%10, end="")
    y += 1

while y - c > 2:
    print(y-2, end="")
    y -= 1

Aucun commentaire:

Enregistrer un commentaire