[Python] printing patterns in python in opposite way [closed]

Discussão em 'Python' iniciado por Stack, Julho 23, 2025.

  1. Stack

    Stack Membro Participativo

    num = 5
    #count =1
    for i in range(num,-1,-1):
    spaces = num - i
    print(" " * space,end="")
    type(spaces)
    for j in range(i):
    print(j,end="")

    # count +=1
    # for k in range(1,count,1):
    # print(" ",end="")


    first i am trying to add spaces using the third loop but in the last i thaught about the lines are wasing so it will take extra memory without the any reason so after that i put my code on copilot he provided me another concept that is " spaces " variable used in code i got the new way to optimize my code

    output:

    01234

    _0123

    __012

    ___01

    ____0

    Continue reading...

Compartilhe esta Página