Skip to content

Instantly share code, notes, and snippets.

@osbre
Last active April 4, 2019 07:38
Show Gist options
  • Save osbre/2d70eea072a4dcda1c030efcbf0702b5 to your computer and use it in GitHub Desktop.
Save osbre/2d70eea072a4dcda1c030efcbf0702b5 to your computer and use it in GitHub Desktop.
rows = [
['x', 'x', 'x', 'x', 'x'],
['x', 'x'],
['x'],
]
for rowIndex, row in enumerate(rows):
nextRowIndex = rowIndex+1
if(nextRowIndex < len(rows)):
nextRow = rows[nextRowIndex]
else:
nextRow = None
for positionIndex, position in enumerate(row):
# якщо наступний рядок існує
if nextRow is not None:
# перевірити чи є така ж позиція
if(positionIndex+1 <= len(nextRow)):
rows[rowIndex][positionIndex] = "f"
rows[nextRowIndex][positionIndex] = "F"
# print rows
for row in rows:
print(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment