Feb-28-2019, 08:02 PM
My isuue for code below is , my code stop working after validate . This is a game with two players and the computer , the score has to save by player name , the game will be 3 rounds. I would like to know why my selection for the menu is not working. Thank you
from random import randint Playernames=[] def validate(): while True: Player1 = input("what is the name of the first player : ") Player2 = input("what is the name of the second player : ") Playernames.append(Player1) Playernames.append(Player2) print(Player1,'and',Player2) if len(Player1 and Player2) < 5: print("Not valid ,please make sure your name is at least 5 letters") elif len(Player1 and Player2 ) > 20: print("Make sure your name has less than 20 letters") else: break validate() while True: print("1.Play Game") print("2.Show Game Rules") print("3.Show Statistics") print("4.Exit") selection=input('Please enter a selection:') if selection == '1': print('player1' or 'player2') Play = eval(input('How many games of Rock-Paper-Scissors do you want to play?:')) while (1): if (Play % 2 == 0): # to check that number is not even Play = int(input('Please enter an odd number of games.:')) else: break choice = ["Rock", "Paper", "Scissors" ,"Saw"] computer=choice[randint(0,3)] player1==false player2==false while player1 and player2==false: player1_win = 0# to count number of wins by user Player2_win = 0 # to count number of wins by user comp_win = 0 # to count number of wins by computer i = 0 player1 = input("Rock, Paper, Scissors, Saw?") if player1 == computer: print("Tie!") elif player1 == "Rock": if computer == "Paper": print("You lose!", computer, "covers", player1) else: print("You win!", player1, "smashes", computer) elif player1 == "Paper": if computer == "Scissors": print("You lose!", computer, "cut", player1) else: print("You win!", player1, "covers", computer) elif player1 == "Scissors": if computer == "Rock": print("You lose...", computer, "smashes", player1) else: print("You win!", player1, "cut", computer) player2 = input("Rock, Paper, Scissors,Saw?") if player2 == computer: print("Tie!") elif player2 == "Rock": if computer == "Paper": print("You lose!", computer, "covers", player2) else: print("You win!", player2, "smashes", computer) elif player == "Paper": if computer == "Scissors": print("You lose!", computer, "cut", player2) else: print("You win!", player2, "covers", computer) elif player == "Scissors": if computer == "Rock": print("You lose...", computer, "smashes", player2) else: print("You win!", player2, "cut", computer)