Aug-13-2018, 12:02 AM
(This post was last modified: Aug-13-2018, 12:04 AM by ichabod801.)
I've been wondering for a while if I could manage a rock-paper-scissors game with these constraints.
""" zen_rps.py A zen Python rock-scissors-paper program. """ import random def zen_rps(rounds): win_loss_draw, wins = [0, 0, 0], {'rock': 'scissors', 'scissors': 'paper', 'paper': 'rock'} for round in range(rounds): you, me = input("What's your move? ").lower().strip(), random.choice(list(wins.keys())) win_loss_draw[1 + (you == me) - 4 * (wins.get(you, '') == me) + bool(print('My move is', me))] += 1 return win_loss_draw
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures