Advertisement
AlimusSifar

Full Pyramid - Toph.co - Beginner

Mar 17th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. """
  2.    *        row = 1: 3 Ssp 1 st                                 :   0 Msp 1 st
  3.   * *       row = 2: 2 Ssp 1 st 1 sp 1 st                       :   1 Msp 2 st
  4.  * * *      row = 3: 1 Ssp 1 st 1 sp 1 st 1 sp 1 st             :   2 Msp 3 st
  5. * * * *     row = 4: 0 Ssp 1 st 1 sp 1 st 1 sp 1 st 1 sp 1 st   :   3 Msp 4 st
  6.  
  7. Starting sp = nRows - row
  8. Middle sp = row - 1
  9. st = row
  10. """
  11. nRows = int(input())
  12.  
  13. row = 1
  14. while row <= nRows:
  15.     string = ''
  16.     Ssp = 0
  17.     while Ssp < (nRows-row):
  18.         string += ' '
  19.         Ssp += 1
  20.    
  21.     star = 1
  22.     while star <= row:
  23.         if star == row:
  24.             string += '*'
  25.         else:
  26.             string += '* '
  27.         star += 1
  28.     print(string)
  29.     row += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement