the if condition is not running even if the condition is true. On line 29 there's a function set_row and on line 31 there's a function set_col. On Line 58 there's an if statement which checks if guess_row1 is equals to set_row and guess_col1=set_col even the condition is true if statement does not run else always run
from random import randint
user1 = {
"name":input("Enter your name"),
"board":[]
}
user2 = {
"name":input("Enter your name"),
"board":[]
}
def set_board(user):
for x in range(5):
user["board"].append(["O"]*5)
def print_board(user):
for row in user["board"]:
print(" ".join(row))
print("")
print("Let's start")
print("")
set_board(user1)
set_board(user2)
print("This is {}'s board".format(user1["name"]))
print_board(user1)
print("")
print("This is {}'s board".format(user2["name"]))
print_board(user2)
def set_row(user1):
return randint(0, len(user1["board"])-1)
def set_col(user1):
return randint(0, len(user1["board"])-1)
print("")
print("Answer for {}".format(user1["name"]))
print(set_row(user1))
print(set_col(user1))
print("")
def set_row2(user2):
return randint(0, len(user2["board"])-1)
def set_col2(user2):
return randint(0, len(user2["board"])-1)
print("Answer for {}".format(user2["name"]))
print(set_row2(user2))
print(set_col2(user2))
print("")
for turnu1 in range(3,0,-1):
print("turn's left for {} ".format(user1["name"]) + str(turnu1))
print("")
guess_row1 = int(input("Enter the row "))
guess_col1 = int(input("Enter the col "))
print("")
if guess_row1==set_row(user1) and guess_col1==set_col(user1):
print("your right")
else:
print("Wrong answer")
Aucun commentaire:
Enregistrer un commentaire