If rowmask will have all bits set , means queen has been placed successfully in all rows and board is displayed
if ( rowmask == all_rows_filled ) : NEW_LINE INDENT v = [ ] NEW_LINE for i in board : NEW_LINE INDENT for j in range ( len ( i ) ) : NEW_LINE INDENT if i [ j ] == ' Q ' : NEW_LINE INDENT v . append ( j + 1 ) NEW_LINE DEDENT DEDENT DEDENT result . append ( v ) NEW_LINE DEDENT