nested loops to print patters code example
Example 1: pyramid pattern in python
n = 3
for i in range(1, n+1):
print(f"{' '*(n-i)}{' *'*i}"[1:])
# Output:
# *
# * *
#* * *
Example 2: * pattern by python
def pattern(n):
for i in range(0,n):
for j in range(0, i+1):
print("* " , end="")
print("\r") pattern(5