Python Forum
issue with if else statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
issue with if else statement
#1
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.

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 ")
Reply


Messages In This Thread
issue with if else statement - by spalisetty06 - Jul-02-2020, 04:13 AM
RE: issue with if else statement - by menator01 - Jul-02-2020, 04:30 AM
RE: issue with if else statement - by spalisetty06 - Jul-02-2020, 04:59 AM
RE: issue with if else statement - by ndc85430 - Jul-02-2020, 05:30 AM
RE: issue with if else statement - by spalisetty06 - Jul-02-2020, 06:11 AM
RE: issue with if else statement - by pyzyx3qwerty - Jul-02-2020, 07:47 AM
RE: issue with if else statement - by spalisetty06 - Jul-02-2020, 07:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Issue using print statement in a thread bweiss1258 9 5,408 Jan-16-2018, 02:07 AM
Last Post: bweiss1258

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020