fork download
  1. def pattern(n):
  2. # Upper part of the pattern
  3. for i in range(1, n + 1):
  4. print('*' * i)
  5.  
  6. # Lower part of the pattern
  7. for i in range(n - 1, 0, -1):
  8. print('*' * i)
  9.  
  10. # Take input from user
  11. n = int(input("Enter the value of n: "))
  12.  
  13. # Call the function
  14. pattern(n)
  15.  
Success #stdin #stdout 0.08s 14184KB
stdin
4
stdout
Enter the value of n: *
**
***
****
***
**
*