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
Post a Comment