I have this, for example, the following characters:
.....U...... L...L.###### .S....#..... ....L.......
which I saved in the list
chars = ['.....U......', 'L...L.######', '.S....#.....', '....L.......']
I used this to store it in characters:
for x in range(0, N): g = input() chars.append(g)
Now the problem is that I want to turn all the points between the letters L into #, but vertically, and so:
.....U...... L...L.###### .S..#.#..... ....L.......
Iβve tried it for several hours, and I canβt think of anything. Many thanks.
EDIT: I used this to connect them horizontally. And it works.
while y != N: modchars0 = list(chars[y]) if modchars0.count('L') == 0: y += 1 else: for k in range(0, M): if 'L' in modchars0[k]: start = k + 1 break for l in range(M-1, 0, -1): if 'L' in modchars0[l]: end = l break for h in range(start, end): if 'L' in modchars0[h]: pass else: modchars0[h] = '#' modchars1 = modchars1.join(modchars0) chars[y] = modchars1 y += 1
source share