I am trying to write a code for the question, but I am unable to get the logic of the code. So can anyone write code to this question using python?

Question:

Mr. Vincent works in a doormat manufacturing company. One day, he designed a new doormat with the following specifications:

- Mat size must be N x M. ( N is an odd natural number, and M is 3 times of N .)
- The design should have ‘WELCOME’ written in the center.
- The design pattern should only use
`|`

,`.`

and`-`

characters.

Input: 7 21

output:

---------.|.---------

------.|..|..|.------

---.|..|..|..|..|.---

-------WELCOME-------

---.|..|..|..|..|.---

------.|..|..|.------

---------.|.---------

## Rashika

This answer was edited.To design a doormat in python, please check the below code

print(“Enter the mat dimensions which must be N*M ( N is an odd natural number, and M is 3 times of N)”)

#read the dimensions convert them into int because by default input will be taken as a string

#Map function iterates over input and reads two dimensions at the same time

N,M = map(int,input().split())

#range starts from 1 to N and increments it by 2

for i in range(1, N, 2):

#str function in python gives the string version of the object

#center function center aligns the string with the specified interval and given character

#so here, starting from 1 to N at every even intervals “.|.” will be printed “i” times at the center and the rest will be filled with “-”

print (( str(‘.|.’)*i ).center(M, ‘-‘))

#welcome will be printed at center, remember N is height M is width

print (str(‘WELCOME’).center(M, ‘-‘))

#range starts from N-2 till -1 and decrements by 2

for i in range(N-2, -1, -2):

#same as that of the above for loop

print (( str(‘.|.’)*i ).center(M, ‘-‘))