We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
N, M = map(int,input().split())
for i in range(1,N,2):
print(('.|.'*i).center(M,'-'))
print('Welcome'.center(M,'-'))
for i in range(N-2,0,-2):
print(('.|.'*i).center(M,'-'))
Then I used list comprehension and my second solution was:
N, M = map(int,input().split())
pattern = [('.|.'*i).center(M,'-') for i in range(1,N,2)]
print('\n'.join(pattern),'\n'+'WELCOME'.center(M,'-'),'\n'+'\n'.join(pattern[::-1]))
Almost identical to your solution but the print was a mess. I saw your comment here and stole that print statement (I don't know why I didn't think of creating one big list then using join to print it effectively, but I have learnt now.)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Designer Door Mat
You are viewing a single comment's thread. Return to all comments →
First solution I submitted was:
Then I used list comprehension and my second solution was:
Almost identical to your solution but the print was a mess. I saw your comment here and stole that print statement (I don't know why I didn't think of creating one big list then using join to print it effectively, but I have learnt now.)