Ask coding questions

← Back to all posts
Need a rock paper scissors code asap!
bellabonura21 (90)

In this unit, you expanded your Python skills, and now you can really have some fun! In this lab, you are going to create a game that allows the user to play Rock, Paper, Scissors against the computer. If you aren’t familiar with this classic game, here’s how it works: two people (or a person and a computer!) each select either rock, paper, or scissors. The player who chooses the stronger object wins. Here is how the winner is determined:

Rock beats scissors because a rock can break scissors.
Paper beats rock because paper can cover a rock.
Scissors beats paper because scissors can cut paper.

Your program should do the following:

Randomly choose rock, paper, or scissors for the computer
Ask the user to choose rock, paper, or scissors
Compare the computer’s choice to the player’s choice
Announce whether the computer or the human won

PLEASE DO IT ASAP!!! I HAVE TRIED FOR SOOOOO LONG!!! HELP!

Answered by RYANTADIPARTHI (6018) [earned 5 cycles]
View Answer
Comments
hotnewtop
bellabonura21 (90)

yes your link did work. thanks! I just still need help with actually putting it on the code..

bellabonura21 (90)

thanks yall! i hoeslt could not do this without you guys! c-ya!

Kookiez (400)

what have you done yet? pls send repl or something, also is this a homework/classwork assignment?

bellabonura21 (90)

that did not work either :( im sorry... i just cant do it!

JBloves27 (1886)

Well, you could do the following:

import random

print("rock paper scissors")

stuff=["rock","paper","scissors"]

while True:
  Input = input("input rock, paper, or scissors ")
  cp = random.choice(stuff)

  if cp == 'rock' and Input == 'paper':
    print("you won")
  elif cp == 'paper' and Input == 'scissors':
    print("you won")
  elif cp == 'scissors' and Input == 'rock':
    print('you won')
  elif cp == 'scissors' and Input == 'paper':
    print('you lost')
  elif cp == 'paper' and Input == 'rock':
    print('you lost')
  elif cp == 'rock' and Input == 'scissors':
    print('you lost')
  else:
    print("its a tie")

That should work, and you can add additional stuff as well

bellabonura21 (90)

did not work :( thx tho

Coder100 (18191)
import random

print('rock paper scissors!')

choices = ['rock', 'paper', 'scissors']

choice = input('ur choice')
computer = 'rock'
computer = random.choice(choices)

if computer == 'rock' and choice == 'paper':
  print("you win!")
elif computer == 'paper' and choice == 'scissors':
  print("you win!")
elif computer == 'scissors' and choice == 'rock':
  print("you win!")
elif computer == 'paper' and choice == 'rock':
  print("you lose!")
elif computer == 'scissors' and choice == 'paper':
  print("you lose!")
elif computer == 'rock' and choice == 'scissors':
  print("you lose!")
else:
  print("tie")

so like simply, all you need to do is check if the computer is like something, and the user choice is defeats computer, then the user wins, and if you see that it is the other way around, evidently the computer wins. At the end, it must be a tie.

working repl: https://repl.it/@Coder100/asd-asdfad-dsfads-ads-fd-asdf-dsafsad-working-tik-tak-toe#main.py

Coder100 (18191)

well what have you tried lol