this is the code, it is supposed to be a game of rock paper scissors
whowon = 0
cchoice = 0
print('Welcome to Rock Paper Scissors!')
while True:
print('To choose Rock, Paper, or Scissors, type 1, 2, or 3 respectively, or\nsimply type
"rock, paper, or scissors".')
for x in range(4):
print(start[x])
time.sleep(.66)
while True:
pinput = str(input())
if str(pinput) == 'rock' or 'Rock' or '1':
pchoice = 1
elif str(pinput) == 'paper' or 'Paper' or '2':
pchoice = 2
elif str(pinput) == 'scissors' or 'Scissors' or '3':
pchoice = 3
else:
print('please type Rock, Paper, Scissors or 1, 2, 3')
continue
break
cchoice = random.randint(1,3)
print('computer choice:' +str(cchoice)+' '+start[cchoice-1]+'\nplayer
choice:'+str(pchoice)+' '+start[pchoice-1]+'\nplayer input'+str(pinput)+'\nwho won calc:'+'
'+str(whowon))
whowon = pchoice / cchoice
if pchoice == 1 and whowon >.4:
print('Paper beats Rock! You Lose!')
else:
print('Rock beats Scissors! You Win!')
if pchoice == 2 and whowon <1:
print('Paper beats Rock! You Win!')
else:
print('Scissors beats Paper! You Lose!')
if pchoice == 3 and whowon <2:
print('Rock beat Scissors! You Win!')
else:
print('Scissors beats Paper! You Lose!')
the if statements in the second while looped(the one embedded in the main loop) are supposed to convert your human answer to a number, rock being 1, paper being 2, and scissors being 3. instead, it always thinks your choice is rock, no matter what input you give.
Aucun commentaire:
Enregistrer un commentaire