Skip to content

Instantly share code, notes, and snippets.

@alevchuk
Last active August 9, 2021 21:21
Show Gist options
  • Save alevchuk/d193181569134db6351e26915db7a8e8 to your computer and use it in GitHub Desktop.
Save alevchuk/d193181569134db6351e26915db7a8e8 to your computer and use it in GitHub Desktop.
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