[Python] Why does my attempt at printing a triangle come out as a straight column?

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

  1. Stack

    Stack Membro Participativo

    My program is not executing the way it should. I am trying to create a right triangle using asterisks in Python 3. I am using the exact code from the text book but it comes out as a straight column:

    size = 7

    for row in range (size):
    for col in range (row + 1):
    print('*', end='')
    print()


    Results in:

    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *
    *

    Continue reading...

Compartilhe esta Página