Python Forum
Automate the boring stuff : the tic tac toe game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automate the boring stuff : the tic tac toe game
#6
Well, say you use for first, second, third in WINS:. The first time through the loop, first is 'top-L', second is 'top-M', and third is 'top-R'. You know how to test for a win with those three strings, right? So use that method to test first, second, and third for a win.

Before the loop over WINS, you set win_exists to False. During the loop, if at any point first, second, and third represent a win, set win_exists to True, and use a break statement to get out of the loop. That way, at the end of the loop, win_exists tells you if the current player won.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Automate the boring stuff : the tic tac toe game - by ichabod801 - Apr-22-2019, 12:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Run the code for some stuff it does not return me why Anldra12 3 2,914 Apr-19-2021, 02:01 PM
Last Post: Anldra12
  "Automate the Boring Stuff with Python" creating a path works but only for CMD promt Milos 2 2,918 Nov-28-2020, 01:08 PM
Last Post: Larz60+
  Unable to print stuff from while loop Nick1507 4 2,407 Sep-17-2020, 02:26 PM
Last Post: Nick1507
  How Do I Install Stuff for Python? CopBlaster 6 3,292 May-08-2020, 12:27 PM
Last Post: hussainmujtaba
  Learning to have Class and doing stuff with it... bako 2 2,048 Apr-29-2020, 05:07 PM
Last Post: bako
  Getting Cells from the Sheets "automate the boring stuff" Shafla 8 4,110 Sep-24-2019, 04:53 AM
Last Post: snippsat
  [split] Automate the boring stuff, inserting commas in list srikanth 1 2,152 Jul-02-2019, 02:29 PM
Last Post: metulburr
  Regex Issue from Automate the Boring Stuff book robgraves 2 2,871 Jun-16-2019, 12:41 AM
Last Post: robgraves
  Automate the boring stuff: regex not matching DJ_Qu 7 3,865 Apr-27-2019, 07:03 AM
Last Post: micseydel
  Automate the boring stuff, inserting commas in list DJ_Qu 3 4,793 Apr-21-2019, 03:52 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

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