Python 石头剪纸中的圈数选择问题
对于这个石头剪刀布游戏,我遇到了一些问题,一个是无法进入比较游戏数量的循环。但在此之前,我没有让它正确地选择一个数字,让计算机选择它抛出的东西。由于我仍在学习如何编码,我希望知道问题是什么Python 石头剪纸中的圈数选择问题,python,python-3.x,Python,Python 3.x,对于这个石头剪刀布游戏,我遇到了一些问题,一个是无法进入比较游戏数量的循环。但在此之前,我没有让它正确地选择一个数字,让计算机选择它抛出的东西。由于我仍在学习如何编码,我希望知道问题是什么 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
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()
我认为它接近于if c或u的东西。
尝试类似于如果c