We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4bb4f39 commit dbfd193Copy full SHA for dbfd193
Pattern2.py
@@ -0,0 +1,32 @@
1
+# Python 3.x code to demonstrate star pattern
2
+
3
+# Function to demonstrate printing pattern triangle
4
+def triangle(n):
5
6
+ # number of spaces
7
+ k = n - 1
8
9
+ # outer loop to handle number of rows
10
+ for i in range(0, n):
11
12
+ # inner loop to handle number spaces
13
+ # values changing acc. to requirement
14
+ for j in range(0, k):
15
+ print(end=" ")
16
17
+ # decrementing k after each loop
18
+ k = k - 1
19
20
+ # inner loop to handle number of columns
21
+ # values changing acc. to outer loop
22
+ for j in range(0, i+1):
23
24
+ # printing stars
25
+ print("* ", end="")
26
27
+ # ending line after each row
28
+ print("\r")
29
30
+# Driver Code
31
+n = 5
32
+triangle(n)
0 commit comments