Last active
August 9, 2021 21:21
-
-
Save alevchuk/d193181569134db6351e26915db7a8e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Before:") | |
A = [[ '#' ' ' [(col + cell) % 2] for col in range(5)] for cell in range(5)] | |
print(A) | |
print("After:") | |
A = [] | |
for col in range(5): | |
A.append([]) | |
for cell in range(5): | |
check = (col + cell) % 2 | |
if check == 0: | |
A[col].append('#') | |
elif check == 1: | |
A[col].append(' ') | |
print(A) | |
# Before: | |
# [['#', ' ', '#', ' ', '#'], [' ', '#', ' ', '#', ' '], ['#', ' ', '#', ' ', '#'], [' ', '#', ' ', '#', ' '], ['#', ' ', '#', ' ', '#']] | |
# | |
# After: | |
# [['#', ' ', '#', ' ', '#'], [' ', '#', ' ', '#', ' '], ['#', ' ', '#', ' ', '#'], [' ', '#', ' ', '#', ' '], ['#', ' ', '#', ' ', '#']] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment