Given an integer number M, N as input. Write a program to print a striped rectangular pattern of M rows and N columns using (+ and -) character.
The first line of input is an integer M.
The second line of input is an integer N.
In the given example the striped rectangular pattern of
7 rows and 5 columns. Therefore, the output should be
+ + + + +
- - - - -
+ + + + +
- - - - -
+ + + + +
- - - - -
+ + + + +
M=int(input())
N=int(input())
for i in range(M):
for j in range(N):
if (i%2==0):
print("+",end=" ")
else:
print("-",end="")
print()
Comments
Leave a comment