mercredi 25 octobre 2017

Rock Paper Scissors PYTHON

Python rock paper scissors working nicely for me. I'm just a bit stumped on how to add up and print the number of times "human" used each weapon....

from random import choice

win = 0
loss = 0
tie = 0


rules = {'Rock': 'Paper', 'Scissors': 'Rock', 'Paper': 'Scissors'}
previous = ['Rock', 'Paper', 'Scissors']


while True:
 human = input('Rock, Paper, Scissors or Quit???: ')
 computer = rules[choice(previous)]  

if human in ('Quit'):
    print("YoU WoN %d TiMEs!" % win)
    print("yOu lOSt %d tImEs!" % loss)
    print("YoU TIeD %d TiMEs!" % tie)
    print("SeE YoU LaTeR!!! :)")

elif human in rules:
    previous.append(human)
    print('tHe CoMPuTeR PlAyEd', computer, end='; ')

    if rules[computer] == human:  
        print('YoU WiN!')
        win += 1
    elif rules[human] == computer:  
        print('ThE CoMpUtER BeAT YOU!!!')
        loss += 1
    else:
        print("It'S A tIE!")
        tie += 1

else: print("that's not a valid choice")

Aucun commentaire:

Enregistrer un commentaire