In this program, I will explain how to define your own exceptions in Python programming language. It will help you to understand the exceptions concept in python.
To increase your Python knowledge, practice all Python programs, here is a collection of 100+ Python problems with solutions.
Copy the below python program and execute it with the help of python compiler.
BOARD_SIZE = 8
left = right = col = queens[-1]
for r in reversed(queens[:-1]):
left, right = left-1, right+1
if r in (left, col, right):
for i in range(BOARD_SIZE):
test_queens = queens + [i]
if len(test_queens) == BOARD_SIZE:
queens = add_queen()
print "\n".join(". "*q + "Q " + ". "*(BOARD_SIZE-q-1) for q in queens)
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.