Python Forum
Tic Tac Toe except Valueerror help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tic Tac Toe except Valueerror help
#2
Rearrange part of your code like that (the rest is OK)

try:
    squareChoice = int(input("Choose a square!")) -1
except ValueError:
    print("\nAnswer is not a number! please enter a valid number!")
    continue

if boardValues[squareChoice] != "X" and boardValues[squareChoice] != "O"
may be re-written as
if boardValues[squareChoice] not in "OX":
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Messages In This Thread
Tic Tac Toe except Valueerror help - by Minindis02 - Jul-10-2018, 06:39 AM
RE: Tic Tac Toe except Valueerror help - by volcano63 - Jul-10-2018, 07:18 AM

Forum Jump:

User Panel Messages

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