0
   

Where is my false

 
 
Reply Wed 1 Sep, 2021 03:34 pm
I was doing rock,paper,scissors game in python but whenever ı run the code it's going to else situation which is(print("Enter right words.")
How can ı fix it ?
import random
list = ["Rock","Paper","Scissors"]
live = 3

while True:
pc_choice = random.choice(list)
your_choice = input("Rock,Paper or Scissors? ")
if(your_choice.lower()=="Rock" and pc_choice.lower()=="Rock"):
print("DRAW!")
elif(your_choice.lower()=="Rock"and pc_choice.lower()=="Paper"):
live-=1
print("You lost. You have {} live".format(live))

elif (your_choice.lower() == "Rock" and pc_choice.lower()=="Scissors"):
print("You win.")

elif(your_choice.lower()=="Paper"and pc_choice.lower()=="Rock"):
print("You win")

elif (your_choice.lower() == "Paper" and pc_choice.lower()=="Paper"):
print("DRAW!")

elif (your_choice.lower() == "Paper" and pc_choice.lower()=="Scissors"):
live-=1
print("You lost.You have {} live".format(live))

elif(your_choice.lower()=="Scissors" and pc_choice.lower()=="Rock"):
live-=1
print("You lost. You have {} live".format(live))

elif (your_choice.lower() == "Scissors" and pc_choice.lower()=="Paper"):
print("You win")

elif (your_choice.lower() == "Scissors" and pc_choice.lower()=="Scissors"):
print("DRAW!")

if(live==0):
print("You have none live you lost.")
break
else:
print("Enter right words.")
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 559 • Replies: 2
No top replies

 
View best answer, chosen by mesutanlak
maxdancona
  Selected Answer
 
  2  
Reply Wed 1 Sep, 2021 03:37 pm
@mesutanlak,
For one thing... your_choice.lower() always returns lower case. Comparing it to "Rock" (which has an upper case letter) will always return false.

Try changing this to your_choice.lower == "rock".
mesutanlak
 
  2  
Reply Wed 1 Sep, 2021 03:40 pm
@maxdancona,
So much thank you man.
0 Replies
 
 

Related Topics

 
  1. Forums
  2. » Where is my false
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 10/09/2024 at 07:22:24