Nested Loop to Generate Triangle

Victor Demelo badbarefoot at gmail.com
Thu May 25 12:32:50 EDT 2017


On Thursday, May 25, 2017 at 12:28:45 PM UTC-4, Victor Demelo wrote:
> I need the triangle to be in reverse. The assignment requires a nested loop to generate a triangle with the user input of how many lines.
> 
> Currently, I get answers such as:
> OOOO
> OOO
> OO
> O
> 
> When I actually need it to be like this:
> OOOO
>   OOO
>    OO
>     O
> 
> 
> I just need to get it flipped-over on the other side.
> 
> Here is the code I have written, thank you.
> 
> 
> 
> base_size = int(input("How many lines? "))
> columns = base_size
>  
> for row in range (base_size) :
>    for columns in range (columns) :
>        print('O', end='')
>    print()




More information about the Python-list mailing list