Oct-06-2017, 02:08 AM
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()
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()