Aug-14-2019, 06:39 PM
Stop and plan a minute. Is board a local variable to a function, as you implement in is_valid_location() and board_create(), or is it global so it need not be passed? Row is defined as global in scope, but then used as both the counter and the limit in a for statement - line 8 is really ugly and scary and prone to stranger things. And, why does board_create() require any arguments when all of the information is global? By naming those arguments you just introduced all kinds of interesting scope problems that will kick you in the, well, yes.
Stop. Think.
wabba = 6 wabbawabba = 12 def abbaw(wabba, wabbawabba) : wabba = wabbawabba print(wabba, wabbawabba) abbaw(wabba, wabbawabba) 12 12 print (wabba, wabbawabba) 6 12So changing wabba in the function did not change the value in the global - same name but different namespace.
Stop. Think.