python - I need to reverse the output format of a printed triangle using O's -



python - I need to reverse the output format of a printed triangle using O's -

i need reverse output format of printed triangle using o's

my code is

userrows=int(input("enter positive number less or equal 20!")); while((userrows>21) or (userrows<0)): userrows=int(input("try again! please come in positive number less or equal 20.")); rows=1; while(rows<=userrows): columns=1; while(columns<=rows): print("o",end=''); columns=columns+1; print(''); rows=rows + 1;

the output is

enter positive number less or equal 20!20 o oo ooo oooo ooooo oooooo ooooooo oooooooo ooooooooo oooooooooo ooooooooooo oooooooooooo ooooooooooooo oooooooooooooo ooooooooooooooo oooooooooooooooo ooooooooooooooooo oooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo

i'm trying align right left, instead of left right(as shown above).

>>> userrows=int(input("enter positive number less or equal 20!")); come in positive number less or equal 20!20 >>> in range(userrows): ... print ' '*(userrows-i)+'0'*i ... 0 00 000 0000 00000 000000 0000000 00000000 000000000 0000000000 00000000000 000000000000 0000000000000 00000000000000 000000000000000 0000000000000000 00000000000000000 000000000000000000 0000000000000000000

python formatting output

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -