Answer to Question #218531 in Python for Saikumar

Question #218531

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


+ + + + +

- - - - -

+ + + + +

- - - - -

+ + + + +

- - - - -

+ + + + +





1
Expert's answer
2021-07-19T16:59:12-0400
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()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS