Computers and Technology

URGENT: I need to add a while loop in this program but I don't know-how. I am also having trouble neatening some lines of code. Here it is:
#This is an RPS program where the user can play until they don't want to.
import random
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? ")
if choice == "y":
import random
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.")
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")
elif choice == "n":
("Thanks for playing!")
else:
print("That is not a vaild option.")
choice = input("Play Again? ")

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:00, kimmosley80
Which if the following allows you to view and access important information about your documents all in one location
Answers: 3
image
Computers and Technology, 21.06.2019 21:20, shadowgirl1213
Write a select statement that returns product name, customer first name, customer last name, channel description, and amount sold for all the sales. make sure to returns sales even if there is no information on the customer, product, or channe
Answers: 2
image
Computers and Technology, 22.06.2019 08:30, electrofy456
Active listen eliminates barries to communication true or false
Answers: 1
image
Computers and Technology, 22.06.2019 14:30, binodkharal2048
Hi plz 11 ! when planning a table, what step comes first: "define the column headers" or "calculate the number of columns/rows"? a. calculate the number of columns/rows b. define the column headers
Answers: 1
Do you know the correct answer?
URGENT: I need to add a while loop in this program but I don't know-how. I am also having trouble ne...

Questions in other subjects: