Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to call a function until it returns 0 in python

Tags:

python

loops

def solveMaze(win, board):  
    mazesol.removeDeadEnds(win, board)

I need to call mazesol.removeDeadends(win,board) until it returns 0. This is what the function does:

This function takes the window as its first argument and the board as its second argument. It sweeps the complete board (skipping the first and last rows and the first and last columns), and converts every position that is a path with exactly one path as a neighbor into a dead end. It returns the number of dead ends that were converted.

like image 975
Jostlyn Avatar asked Feb 20 '26 23:02

Jostlyn


1 Answers

Is there something wrong with:

while mazesol.removeDeadends(win,board): pass

or

while mazesol.removeDeadends(win,board): print ".",

or

 a = 1
 while a:
   a = mazesol.removeDeadends(win,board)
   print "Removed", a
like image 64
Carl F. Avatar answered Feb 22 '26 13:02

Carl F.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!