subject

I wrote a rock paper scissors game in python but I cannot get it to play again once the user choices a yes option. The rest of the program works. Here's what I have:
import random
playAgain = True
choice = input("Enter Rock(R), Paper(P), or Scissors(S): ")
computer = random. randint(1, 3)
if computer == 1:
print("Computer played R.")
elif computer == 2:
print("Computer played P.")
else:
print("Computer played S.")
#Winning conditions
if computer == 1 and choice == "R":
print("Computer played Rock.")
print("Tie")
elif computer == 2 and choice == "P":
print("Computer played Paper.")
print("Tie")
elif computer == 3 and choice == "S":
print("Computer played Scissors.")
print("Tie")
elif computer == 1 and choice == "S":
print("Computer played Rock.")
print("You Lose")
elif computer == 2 and choice == "R":
print("Computer played Paper.")
print("You Lose")
elif computer == 3 and choice == "P":
print("Computer played Scissors.")
print("You Lose")
elif computer == 1 and choice == "P":
print("Computer played Rock.")
print("You Win")
elif computer == 2 and choice == "S":
print("Computer played Paper.")
print("You Win")
elif computer == 3 and choice == "R":
print("Computer played Scissor.")
print("You Win")
#Play again?
choice = input("Play Again? ")
while playAgain == True:
if choice == "y":
playAgain = True
elif choice == "yes":
playAgain = True
if choice == "Yes":
playAgain = True
elif choice == "Y":
playAgain = True
elif choice == "n":
print("Thanks for playing!")
exit()
elif choice == "no":
print("Thanks for playing!")
exit()
elif choice == "N":
print("Thanks for playing!")
exit()
elif choice == "No":
print("Thanks for playing!")
exit()
else:
print("Please input a vaild option.")
choice = input("Play Again? ")

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
In the context of an internet connection, llc stands for leased line connection liability limited company local loop complex local loop carrier
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
You have read about the beginnings of the internet and how it was created. what was the internet originally created to do? (select all that apply) share research. play games. communicate. share documents. sell toys
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
File account.java (see previous exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a string representation. note that the constructor for this class creates a random account number. save this class to your directory and study it to see how it works. then write the following additional code: 1. suppose the bank wants to keep track of how many accounts exist. a. declare a private static integer variable numaccounts to hold this value. like all instance and static variables, it will be initialized (to 0, since it’s an int) automatically. b. add code to the constructor to increment this variable every time an account is created. c. add a static method getnumaccounts that returns the total number of accounts. think about why this method should be static - its information is not related to any particular account. d. file testaccounts1.java contains a simple program that creates the specified number of bank accounts then uses the getnumaccounts method to find how many accounts were created. save it to your directory, then use it to test your modified account class.
Answers: 3
question
Computers and Technology, 24.06.2019 01:30
Write a program that asks the user to enter the name of an input file. if the file does not exist, the program should prompt the user to enter the file name again. if the user types quit in any uppercase/lowercase combinations, then the program should exit without any further output.
Answers: 3
You know the right answer?
I wrote a rock paper scissors game in python but I cannot get it to play again once the user choices...
Questions
question
Spanish, 24.09.2019 20:00
Questions on the website: 13722360