fork download
  1. rows = 5
  2. for i in range(0, rows):
  3. for j in range(0, i + 1):
  4. print("*", end=' ')
  5. print("\r")
  6.  
  7. for i in range(rows, 0, -1):
  8. for j in range(0, i - 1):
  9. print("*", end=' ')
  10. print("\r")
  11.  
  12. rows = 5
  13. i = 1
  14. while i <= rows:
  15. j = i
  16. while j < rows:
  17. # display space
  18. print(' ', end=' ')
  19. j += 1
  20. k = 1
  21. while k <= i:
  22. print('*', end=' ')
  23. k += 1
  24. print()
  25. i += 1
  26.  
  27. i = rows
  28. while i >= 1:
  29. j = i
  30. while j <= rows:
  31. print(' ', end=' ')
  32. j += 1
  33. k = 1
  34. while k < i:
  35. print('*', end=' ')
  36. k += 1
  37. print('')
  38. i -= 1
Success #stdin #stdout 0.03s 9580KB
stdin
Standard input is empty
stdout
* 
* * 
* * * 
* * * * 
* * * * * 
* * * * 
* * * 
* * 
* 

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