Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation checking
#20
I'd like to help but I am not familiar with game 4 in row and I have very little understanding what the code should do.

Therefore only nitpicking.

name 'game_over'. Wouldn't it be more logical to have 'game'.
Instead of:

game_over = False
while not game over:
To have:

game = True
while game:
I can't see that game_over is used anywhere except in while loop threfore one can skip it altogether:

while True:
In order to break out from while loop you must set looping condition so that it will stop if criteria is met. There is no change of value game_over and this loop will go on indefinitely.

There are nested while loops and breaking out from inner and outer can be tricky. Recommended practice is to use function instead of nested while-loop.

There are also (unnecessary) conversions and rows.

I would recommend to have a plan along those lines:

# validate user input for creating board
# validate user input of choices and .... /what should happen?
# how to determine when winning state is achieved (is this a game where should be a winner?)
# implement whatever rules the game has
# etc
# output winner

EDIT:

There is nice tutorial on this forum written by ichabod801 Validating User Input
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Validation checking - by Help_me_Please - Aug-14-2019, 01:31 PM
RE: Validation checking - by buran - Aug-14-2019, 01:35 PM
RE: Validation checking - by perfringo - Aug-14-2019, 01:39 PM
RE: Validation checking - by Help_me_Please - Aug-14-2019, 01:43 PM
RE: Validation checking - by perfringo - Aug-14-2019, 01:52 PM
RE: Validation checking - by Help_me_Please - Aug-14-2019, 03:41 PM
RE: Validation checking - by perfringo - Aug-14-2019, 07:55 PM
RE: Validation checking - by ichabod801 - Aug-14-2019, 05:01 PM
RE: Validation checking - by jefsummers - Aug-14-2019, 06:39 PM
RE: Validation checking - by Help_me_Please - Aug-15-2019, 02:17 PM
RE: Validation checking - by ichabod801 - Aug-15-2019, 03:06 PM
RE: Validation checking - by Help_me_Please - Aug-15-2019, 03:33 PM
RE: Validation checking - by ichabod801 - Aug-15-2019, 03:36 PM
RE: Validation checking - by Help_me_Please - Aug-15-2019, 04:03 PM
RE: Validation checking - by buran - Aug-15-2019, 04:51 PM
RE: Validation checking - by ichabod801 - Aug-15-2019, 04:54 PM
RE: Validation checking - by Help_me_Please - Aug-16-2019, 09:40 AM
RE: Validation checking - by perfringo - Aug-16-2019, 10:17 AM
RE: Validation checking - by jefsummers - Aug-16-2019, 11:46 AM
RE: Validation checking - by perfringo - Aug-16-2019, 12:11 PM
RE: Validation checking - by ichabod801 - Aug-16-2019, 12:33 PM
RE: Validation checking - by Help_me_Please - Aug-16-2019, 12:46 PM
RE: Validation checking - by jefsummers - Aug-16-2019, 02:18 PM
RE: Help please stuck with summer work - by nilamo - Aug-15-2019, 04:47 PM
Connect 4 - by Help_me_Please - Aug-16-2019, 11:38 AM

Forum Jump:

User Panel Messages

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