-
Notifications
You must be signed in to change notification settings - Fork 0
/
Star Pattern
50 lines (39 loc) · 921 Bytes
/
Star Pattern
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Print the following pattern
Pattern for N = 4
Hint
As taught in the video, you just have to modify the code so that instead of printing numbers, it should output stars ('*').
Input Format :
N (Total no. of rows)
Output Format :
Pattern in N lines
Constraints :
0 <= N <= 50
Sample Input 1 :
3
Sample Output 1 :
*
***
*****
Sample Input 2 :
4
Sample Output 2 :
*
***
*****
*******
____________________________________________________________________
solution for this code is
def print_pattern(n):
for i in range(1, n+1):
# Print spaces
for j in range(n-i):
print(" ", end='')
# Print stars
for k in range(1, 2*i):
print("*", end='')
print()
# Taking input from user
n = int(input())
# Printing pattern
print_pattern(n)
________________________________________________________________________________________