0
How Can I make a program that print pattern with the help of boolean variable as input()?
Pattern printing with the help of for loop
7 Answers
+ 1
Try this modify it
n = int(input())
m = n >= 0
for i in range((not m) * n, m * n):
print(abs(i) * '*')
+ 1
What kind of pattern?
n = int(input())
for i in range(0, n):
print(i * '*')
0
*
**
***
****
*****
0
This type if input is true
0
*****
****
***
**
*
This if input is false
0
def pattern( grow = True, rows = 5 ):
stars = 1 if grow else rows
for i in range( rows ):
print( '* ' * stars )
stars = stars +1 if grow else stars - 1
print()
# input 0 for false, non-zero number for true
pattern( bool( int( input() ) ) )