Hi
I've written a rock paper scissors game now want to code in 'Best of 3' logic. Right now, it plays 3 times and then exits.
Any advice will be appreciated. Thanks.
I've written a rock paper scissors game now want to code in 'Best of 3' logic. Right now, it plays 3 times and then exits.
Any advice will be appreciated. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
mychoice = [] for i in range ( 3 ): mychoice = input ( "Please enter your choice of rock, paper or scissors?\n" ).lower() while mychoice not in [ "rock" , "paper" , "scissors" ]: print ( "Please spell correctly.\n" ) mychoice = input ( "Please enter your choice of rock, paper or scissors?\n" ).lower() list = [ "rock" , "paper" , "scissors" ] import random compchoice = random.choice( list ) print ( "Computer chose" + " - " + compchoice) if mychoice = = compchoice: print ( "We chose the same things. Let's play again.\n" ) break if mychoice = = 'rock' and compchoice = = 'scissors' : Result1 = "You win.\n" print (Result1) elif mychoice = = 'rock' and compchoice = = 'paper' : Result2 = "I win.\n" print (Result2) if mychoice = = 'paper' and compchoice = = 'scissors' : Result2 = "I win.\n" print (Result2) elif mychoice = = 'paper' and compchoice = = 'rock' : Result1 = "You win.\n" print (Result1) if mychoice = = "Scissors" and compchoice = = 'paper' : Result1 = "You win.\n" print (Result1) elif mychoice = = "Scissors" and compchoice = = 'rock' : Result2 = "I win.\n" print (Result2) break |