Ask coding questions

← Back to all posts
Trying to make a rock paper scissor game for school
MiguelM1 (2)

I have no experience with Python or any coding. Doing this because it's part of my school curriculum. Please help!

AlexanderBirabe (101)

You're making a lot of syntax errors. Here's a correct version:

import random

rock = 1
paper = 2
scissors = 3

#generating random num
rannum = random.randint(1,3)
getnum = input("Pick a number between 1 and 3")

if (rannum == rock):
  if (getnum == rock):
    print("Computer throws rock. It is a draw.")
  elif (getnum == paper):
    print("Computer throws rock. User wins.")
    print("Computer throws rock. Computer wins.")

elif (rannum == paper):
  if (getnum == rock):
    print("Computer throws paper. Computer wins.")
  elif (getnum == paper):
    print("Computer throws paper. It is a draw.")
    print("Computer throws paper. User wins.")

elif (rannum == scissors):
  if (getnum == rock):
    print("Computer throws scissors. User wins.")
  elif (getnum == paper):
    print("Computer throws scissors. Computer wins.")
    print("Computer throws scissors. It is a draw.")

It looks like a lot of your code is formatted for JavaScript such as the Math.random(), //, &&, let, else if, { }, and ;. If you are looking up help, make sure you include the word 'python' in your search to get results that will be compatible with Python. Also, when you are printing text, make sure you use a ' or a ", but not a as it will not be recognised.

AlexanderBirabe (101)

If you feel this answers your full question, mark it as the answer. @MiguelM1