Jul-02-2020, 04:13 AM
(This post was last modified: Jul-02-2020, 04:13 AM by spalisetty06.)
Hello,
I have tried to program something simple as I am a beginner. But it always executes else part, I don't know why. Please correct my code.
I have tried to program something simple as I am a beginner. But it always executes else part, I don't know why. Please correct my code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import random Player1 = [ "Rock" , "Paper" , "Scissor" ] Player2 = [ "Rock" , "Paper" , "Scissor" ] Player1 = random.choice(Player1) Player2 = random.choice(Player2) print ( "Player1 and Player2 are " ,Player1, Player2) choice = input ( "Please select your choice by entering Y or N " ) while choice! = 'N' : if Player1 = = "Rock" and Player2 = = "Paper" : print ( "Player2 is the winner" ) choice = input ( "Please select your choice by entering Y or N " ) elif Player1 = = "Rock" and Player2 = = "Scissor" : print ( "Player1 is the winner" ) choice = input ( "Please select your choice by entering Y or N " ) else : print ( "No loser" ) choice = input ( "Please select your choice by entering Y or N " ) |