How to multiply layers without ankwardly repeating elif lines? Cannot get += 1 working. Or perhaps different string approach? I'm certainly new in Python.
layer = int(input("Give a number between 2 and 26: "))
table_size = layer + layer - 1
ts = table_size
center = (ts // 2)
for row in range(ts):
for col in range(ts):
if row == col == (center):
print("A", end="")
elif (row > center or col > center \
or row < center or col < center) \
and row < center + 2 and row > center - 2 \
and col < center + 2 and col > center - 2 :
print("B", end="")
elif (row > center+1 or col > center+1 \
or row < center-1 or col < center-1) \
and row < center+3 and row > center-3 \
and col < center+3 and col > center-3 :
print(chr(67), end="")
else:
print(" ", end="")
print()
CCCCC
CBBBC
CBABC
CBBBC
CCCCC
Aucun commentaire:
Enregistrer un commentaire