Facebook
From Stained Partdridge, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 53
  1. data = [[1,0,0], [1,2,0], [1,0,2]]
  2. row = 0
  3. taken = []
  4. gameround = 0
  5. invalidusage = ""
  6. invalidrange = ""
  7.  
  8. while gameround  < 9:
  9.   rowchoice = int(input("Pick a row between 1 and 3 - "))
  10.   columnchoice = int(input("Pick a column between 1 and 3 - "))
  11.   chosensquare = (rowchoice + columnchoice)
  12.   taken.append(chosensquare)
  13.   count = taken.count(chosensquare)
  14.  
  15.   if count > 0 and gameround > 0:
  16.     invalidusage = "yes"
  17.   if chosensquare > 3 or chosensquare < 1:
  18.     invalidrange = "yes"
  19.  
  20.   while invalidusage == "yes" and invalidrange == "yes":
  21.     print("invalid")
  22.     rowchoice = int(input("Pick a row between 1 and 3 - "))
  23.     columnchoice = int(input("Pick a column between 1 and 3 - "))
  24.     chosensquare = (rowchoice + columnchoice)
  25.     taken.append(chosensquare)
  26.     count = taken.count(chosensquare)
  27.  
  28.     if count > 0 and gameround > 0:
  29.       invalidusage = "yes"
  30.     if chosensquare > 3 or chosensquare < 1:
  31.       invalidrange = "yes"
  32.  
  33.    
  34.  
  35.   while row < 3:
  36.     col = 0
  37.     temp = ""
  38.     while col < 3:
  39.       if data[row][col] == 0: temp = temp + " "
  40.       elif data[row][col] == 1: temp = temp + "X"
  41.       else: temp = temp + "o"
  42.       col = col + 1
  43.     print(temp)
  44.     gameround = gameround + 1
  45.     row = row + 1
  46.