mardi 22 août 2023

Why is my python code printing this weird pattern?

I am trying to solve the following pattern: enter image description here

And here is the code that I wrote:

limit = 10
for i in range(1, 12):
    for j in range(i):
        print(" "*j, end="")

    if limit >= 0:
        for j in range(0, limit):
            print(j, end="")

    limit -= 1
    print()

But it is printing this weird pattern:

enter image description here

Aucun commentaire:

Enregistrer un commentaire