Jan-02-2018, 01:50 PM
(Jan-01-2018, 08:55 PM)ShadowWarrior17 Wrote: But what is wrong with my function?
Also, I'm not checking if a row is full, but if the lowest position in a column is full, just like gravity in Connect 4.
row6="| | | | | | | |" # 012345678 def columncheck(c): x=5 pos=False while pos != True: if dboard[x][(4*c)-1]== " ": pos=True elif dboard[x][(4*c)-1] != " ": x-=1 return xI copied your code from a previous post and added indices to see how things lined up. According to my cut-and-paste, if c == 1, you're checking dboard[5][3]. Is that were you're putting the 'X'? Probably not. Larz approach is going to be much less error-prone than encoding this into a string.
I assume you're starting your column-counting at 1? That's a bad habit to get into... we programmers like to start with zero.