Skip to content

Latest commit

 

History

History
37 lines (32 loc) · 862 Bytes

diamond_pattern.md

File metadata and controls

37 lines (32 loc) · 862 Bytes

Python program to print The Diamond Pattern.

def Diamond(rows): 
    n = 0
    for i in range(1, rows + 1): 
        # loop to print spaces 
        for j in range (1, (rows - i) + 1): 
            print(end = " ") 
          
        # loop to print star 
        while n != (2 * i - 1): 
            print("*", end = "") 
            n = n + 1
        n = 0
          
        # line break 
        print()  
  
    k = 1
    n = 1
    for i in range(1, rows): 
        # loop to print spaces 
        for j in range (1, k + 1): 
            print(end = " ") 
        k = k + 1
          
        # loop to print star 
        while n <= (2 * (rows - i) - 1): 
            print("*", end = "") 
            n = n + 1
        n = 1
        print() 
  
# Finally how many rows of dimaoond you want we can specify.
rows = 5
Diamond(rows) 
```python