How to update a variable after a loop using list comprehension

I have a code that print something like:

N, M = map(int,input().split())
x='.|.'
j=1
for i in range(N):
    print((x*j).center(M,'-'))
    j+=2

I have tried to shorten the code by using list comprehension:

[print((x*j).center(M,'-')) for i in range(N)]

How can I update the variable j for each loop? Thanks.


Solution 1:

I have worked around the problem using this:

[print((x*(1+i*2)).center(M,'-')) for i in range(N)]

This solution maybe short but I think it's not ideal for developing.