Star pattern in python
Very simple star pattern in python
"""
In this pattern
let i = no of rows and j = no of columns
* so, here i = j
** here i = j
*** here i = j
**** here i = j
.
.
.
In this pattern the no of columns are same as rows.
so loops will nested.
and first loop will be 0 to n(rows).
and second loop will o to i(columns).
"""
n = int(input("Enter how many lines you want to print : "))
# input function return a string value but we need integer so int("")
it will type cast into integer.
# n = no of lines
for i in range(0,n+1):
# range function take to values (from, to-1) so i have add 1.
for j in range(0,i):
print("*", end=" ")
# Here print function is add a new line by default but we
need here a space so give a agument end=" ".
print()
# after every line we need a new line for that we use it.
Star pattern in python
Reviewed by Coding Arc
on
January 16, 2021
Rating:
No comments: