Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rock Paper Scissors
#1
I seem to have an issue with getting this program to enter the loops correctly and the computer to generate a random number to compare against the user's input. The indenting didn't copy over correctly but I believe all of it is right.

from random import randint

def rock_paper_scissors():
w = int(input('How many rounds to win? '))
u = int(0)
c = int(0)
r = int(1)
if c or u < w:
print ('Round #', r)
ut = input('Do you throw Rock (1), Paper (2), or Scissors (3)? ')
ct = randint(1, 3)
print ('Computer threw', ct)
if ut == ct:
print (Tie)
print ('Score:'
'Computer:', c,
'User:', u)
if ut == 1 and ct == 2:
print ('Computer wins')
c += 1
r =+ 1
print ('Score:'
'Computer:', c,
'User:', u)
if ut == 1 and ct == 3:
print ('You win')
u +=1
r +=1
print ('Score:'
'Computer:', c,
'User:', u)
if ut == 2 and ct == 1:
print ('You win')
u += 1
r += 1
print ('Score:'
'Computer:', c,
'User:', u)
if ut == 2 and ct == 3:
print ('Computer wins')
c += 1
r += 1
print ('Score:'
'Computer:', c,
'User:', u)
if ut == 3 and ct == 1:
print ('Computer wins')
c += 1
r +=1
print ('Score:'
'Computer:', c,
'User:', u)
if ut == 3 and ct == 2:
print ('You win')
u += 1
r += 1
print ('Score:'
'Computer:', c,
'User:', u)
if c == w:
print ('Computer wins')
if u == w:
print ('You win')

def main():
print('ROCK PAPER SCISSORS in Python')
print()
print('Rules: 1) Rock wins over Scissors.')
print(' 2) Scissors wins over Paper.')
print(' 3) Paper wins over Rock.')

rock_paper_scissors()

main()
Reply


Messages In This Thread
Rock Paper Scissors - by Warmlawpk441 - Oct-06-2017, 02:08 AM
RE: Rock Paper Scissors - by ichabod801 - Oct-06-2017, 02:15 AM
RE: Rock Paper Scissors - by Warmlawpk441 - Oct-07-2017, 06:30 PM
RE: Rock Paper Scissors - by ichabod801 - Oct-07-2017, 06:33 PM
RE: Rock Paper Scissors - by gruntfutuk - Oct-11-2017, 10:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I attempted to make a rock paper scissors bot for homework Intellectual11 3 2,937 Jun-24-2021, 08:00 PM
Last Post: deanhystad
Question Rock, paper, scissors spelling error banidjamali 6 3,272 Jan-19-2021, 02:51 PM
Last Post: banidjamali
  Rock, Paper, Scissors Game kramon19 2 5,389 Jan-10-2020, 08:18 AM
Last Post: perfringo
  I need help with a python Rock Paper Scissors game urgently. Riff_Raff 3 5,886 Dec-05-2018, 09:13 PM
Last Post: nilamo
  Rock, Paper, Scissors Advanced that saves, loads, and keeps statistics EvanCahill 0 5,231 Jul-21-2018, 07:32 PM
Last Post: EvanCahill
  Rock paper scissors game samiraheen 3 6,389 Oct-03-2017, 07:07 PM
Last Post: buran
  The Python Book altered rock paper scissors Python_Noob 0 2,932 Sep-18-2017, 06:13 AM
Last Post: Python_Noob
  HELP---problems with rock paper scissors games kalt91 2 4,157 Sep-15-2017, 04:51 PM
Last Post: micseydel
  Rock, Paper, Scissors game help.. hentera 3 5,092 May-19-2017, 10:56 PM
Last Post: ichabod801
  Rock Paper Scissors game codeobri 3 13,453 Apr-28-2017, 01:02 AM
Last Post: codeobri

Forum Jump:

User Panel Messages

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