samedi 22 février 2020

List reverse is not working for my pattern?

I need to make a patter like this:

---------.|.---------
------.|..|..|.------
---.|..|..|..|..|.---
-------WELCOME-------
---.|..|..|..|..|.---
------.|..|..|.------
---------.|.---------

The problem is that i can't reverse the second part which is the same as the first part just reversed.

Here is my code:

for i in range(n // 2):
   pattern = [('.|.' * (2 * i + 1)).center(m, '-')]
   print('\n'.join(pattern))

print('WELCOME'.center(m, '-'))

for i in range(n // 2):
   pattern = [('.|.' * (2 * i + 1)).center(m, '-')]
   print('\n'.join(pattern[::-1]))

The patter[::-1] should be the reversed one.

Aucun commentaire:

Enregistrer un commentaire