Python Forum
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rock, Paper, scissors
#4
I apologize for the delay. Here is the clean code from my pc.
#Rock Paper Scissor
def game():
   import random
   Dic = {1:"R", 2:"P", 3:"S"}
   PC_Choice = Dic[random.randint(1, 3)]
   print (PC_Choice) #Debugging
   print("Please type R for Rock, P for Paper or S for Scissors")
   User_Choice = input().upper

   if PC_Choice == "R" and User_Choice == "R":
       print("The PC chose rock, it's a tie")

   elif PC_Choice == "R" and User_Choice == "P":
       print("The PC chose rock, you win.")

   elif PC_Choice == "R" and User_Choice == "S":
       print("The PC chose rock, you lose.")

   elif PC_Choice == "P" and User_Choice == "R":
       print("The PC chose paper, you lose.")

   elif PC_Choice == "P" and User_Choice == "P":
       print("The PC chose paper, it's a tie")

   elif PC_Choice == "P" and User_Choice == "S":
       print("The PC chose paper, you win.")

   elif PC_Choice == "S" and User_Choice == "R":
       print("The PC chose scissors, you win.")
   elif PC_Choice == "S" and User_Choice == "P":
       print("The PC chose scissors, you lose.")
   elif PC_Choice == "S" and User_Choice == "S":
       print("The PC chose scissors, it's a tie.")
   else:
       print("Wait what?") #This is for testing the game

   game()
game()
#Game loops
Output:
Wait, what?
Reply


Messages In This Thread
Rock, Paper, scissors - by OmarBrikaa - Jul-07-2017, 06:37 PM
RE: Rock, Paper, scissors - by sparkz_alot - Jul-07-2017, 07:12 PM
RE: Rock, Paper, scissors - by nilamo - Jul-07-2017, 08:53 PM
RE: Rock, Paper, scissors - by OmarBrikaa - Jul-10-2017, 09:55 AM
RE: Rock, Paper, scissors - by ichabod801 - Jul-10-2017, 12:03 PM
RE: Rock, Paper, scissors - by OmarBrikaa - Jul-11-2017, 09:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock Paper Scissors Project in Python ankitdixit 8 4,987 Feb-23-2024, 03:14 PM
Last Post: DPaul
  Trying to create a visual rock paper scissors game urmom33 1 1,085 Dec-03-2022, 09:12 PM
Last Post: deanhystad
  Rock paper scissors in python with "algorithm" Agat0 23 6,299 Mar-01-2022, 03:20 PM
Last Post: Agat0
  Problem restricting user input in my rock paper scissors game ashergreen 6 4,700 Mar-25-2021, 03:54 AM
Last Post: deanhystad
  Odd behavior with Rock Paper Scissor game DustinKlent 2 2,003 Aug-27-2020, 03:55 PM
Last Post: DustinKlent
  Trying to implement Best of 3 logic in rock paper scissors game ShAhCh 5 3,440 May-11-2020, 04:31 PM
Last Post: ShAhCh
  Rock Paper Scissors with dictionaries ewgreht 2 3,954 May-01-2020, 03:19 PM
Last Post: deanhystad
  Rock, Paper, Scissors.. Help..hidden bug xxunknownxx 4 2,723 Mar-19-2020, 02:46 AM
Last Post: jefsummers
  Problem with Basic Rock Paper Scissors code BirinderSingh 3 2,537 Sep-13-2019, 03:28 PM
Last Post: ichabod801
  Rock, Paper, Scissors Help jyou99 1 2,492 Mar-26-2018, 04:07 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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