I wanna make pattern by algorithm.
Result is the pattern like
..........
..........
..........
..........
..........
..........
.########.
.########.
##########
##########
But my ideal pattern is
##......##
##......##
.##....##.
.##....##.
..##..##..
..##..##..
...####...
...####...
....##....
....##....
So,I cannot understand why I cannot do it in my code. By comparing current pattern & ideal one,I think data cannot use correctly. But I cannot know how to fix this. What should I do to do it?
A different approach:
final = []
for i in range(10):
temp = ["." for j in range(10)]
temp[int(i / 2)] = "#"
temp[int(i / 2) + 1] = "#"
temp[-int(i / 2) - 1] = "#"
temp[-int(i / 2) -2] = "#"
final.append(temp)
for a in final:
print("".join(a))
Will print:
##......##
##......##
.##....##.
.##....##.
..##..##..
..##..##..
...####...
...####...
....##....
....##....
This can be made even cleaner, but here you can see all the different steps, so I hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With