Python Forum
Simple Function Problem, please help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Function Problem, please help
#8
row6="|   |   |   |   |   |   |   |"
row5="|   |   |   |   |   |   |   |"
row4="|   |   |   |   |   |   |   |"
row3="|   |   |   |   |   |   |   |"
row2="|   |   |   |   |   |   |   |"
row1="|   |   |   |   |   |   |   |"
dboard=[row6,row5,row4,row3,row2,row1]
l="-----------------------------"


def drawboard():
    print("| 1 | 2 | 3 | 4 | 5 | 6 | 7 |")
    print(l)
    for x in dboard:
        print(x)
        print(l)

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 x
That is my part of my code. It will be a connect 4 game, the function should check if the most bottom row full. Hopefully that adds some context. The problem is that no matter what, the function columncheck©, will ALWAYS return five, whether the position is taken or not.
Reply


Messages In This Thread
RE: Simple Function Problem, please help - by mpd - Dec-28-2017, 02:43 AM
RE: Simple Function Problem, please help - by mpd - Jan-02-2018, 01:50 PM
RE: Simple Function Problem, please help - by ShadowWarrior17 - Dec-31-2017, 05:23 PM
RE: Simple Function Problem, please help - by mpd - Jan-02-2018, 11:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  A simple problem, how best to solve it? SuchUmami 2 787 Sep-01-2023, 05:36 AM
Last Post: Pedroski55
  How to solve this simple problem? Check if cvs first element is the same in each row? thesquid 2 1,328 Jun-14-2022, 08:35 PM
Last Post: thesquid
Big Grin question about simple algorithm to my problem jamie_01 1 1,756 Oct-04-2021, 11:55 AM
Last Post: deanhystad
  simple login problem MMOToaster 2 2,465 Feb-25-2020, 09:28 AM
Last Post: MMOToaster
  got SyntaxError while building simple function zarize 2 2,217 Feb-14-2020, 10:51 AM
Last Post: zarize
  Problem with simple 3D Vektor calculation Pythocodras 0 1,756 Dec-11-2019, 07:18 PM
Last Post: Pythocodras
  Simple statistics with range function Pythonlearner2019 2 2,202 Nov-25-2019, 05:25 PM
Last Post: Pythonlearner2019
  Simple problem. looking for an efficient way silverchicken24 3 2,420 Oct-14-2019, 07:13 PM
Last Post: Larz60+
  Cannot get simple i/o to function. jerryi 10 6,871 Jul-27-2019, 06:22 PM
Last Post: jerryi
  simple string & input problem kungshamji 5 3,788 Jun-23-2019, 03:54 PM
Last Post: kungshamji

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020