error: "no type object has no attribute to format", why do I this problem?

85 views Asked by At

I am a beginner to python and doing my first project on tic tac toe game. Even though reading on what the error means, I was able to identify what's causing it, but not how to solve it. here is the full script:

ox = input("what player are you?")
pos = eval(input("what is your number?"))
def board(player, position):
  if(position == 1,2,3):
    options = {1:" {} | - | -\\n",2:" - | {} | -\\n",3:" - | - | {}\\n"}
    right_option = options.get(position)   
    on_the_go = right_option  
    print(on_the_go.format(player)) 
    print("-----------\\n")
    print(" - | - | - \\n")
    print("-----------\\n")
    print(" - | - | - \\n")

  elif(position == 4,5,6):
   print(" - | - | - \\n")
   print("-----------\\n")
   options = {4:" {} | - | -\\n",5:" - | {} | -\\n",6:" - | - | {}\\n"}
   right_option = options.get(position)  
   on_the_go = right_option
   print(on_the_go.format(player))
   print("-----------\\n")
   print(" - | - | - \\n")

  elif(position == 7,8,9):
   print(" - | - | - \\n")
   print("-----------\\n")
   print(" - | - | - \\n")
   print("-----------\\n")
   options = {7:" {} | - | -\\n",8:" - | {} | -\\n",9:" - | - | {}\\n"}
   right_option = options.get(position)  
   on_the_go = right_option  
   print(on_the_go.format(player))

 else:
   print("you got the wrong number! type again!")

board(ox, pos)

what I am trying to do here is to create "ability to mark a sign on the board game". this means only checking if the when the player picks a slot, and marks it, hence it would be marked in the right position, and in the right sign.

I tried running the program only by one statement at a time (if, elif, else) while running only the if statement in the board function. it worked just fine. when checking only one different statement (elif), it worked fine too. thus I concluded that the problem is in the relation between the statements. there is no syntax error I find, no logical problem with how the function works, the burden is with the statements on def board. I think that there might be some sort of a knowledge gap in how the combination of "if", "elif" and "else" operates, and how it shouldn't work. although I am unable to find how. I may add that in the script there is probably an indentation problem, but there is nothing to do with the problem.

0

There are 0 answers