forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatterns.py
More file actions
39 lines (29 loc) · 717 Bytes
/
patterns.py
File metadata and controls
39 lines (29 loc) · 717 Bytes
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
# Lets say we want to print a combination of stars as shown below.
# *
# * *
# * * *
# * * * *
# * * * * *
# Let's say we want to print pattern which is opposite of above:
# * * * * *
# * * * *
# * * *
# * *
# *
def main():
lines = int(input("Enter no.of lines: "))
pattern(lines)
def pattern(lines):
for i in range(lines):
for j in range(i+1):
print("* ", end="")
print("")
print(" ")
for i in range(0,lines):
for j in range(0, (2 * (i - 1)) + 1):
print(" ", end="")
for j in range(0, lines - i):
print("*", end=" ")
print("")
if __name__ == "__main__":
main()