Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
chatbot-final/rps.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (28 sloc)
887 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rps(): | |
import random | |
moves=["rock","paper","scissors"] | |
while True: | |
c = random.choice(moves) | |
p = input("Choose your move: rock, paper, or scissors? ") | |
if not(p == "rock" or p == "paper" or p == "scissors"): | |
print("Try again - enter the words exactly as they are written") | |
pass | |
else: | |
print("I chose",c) | |
if c == p: | |
print("Tie, let's play again") | |
elif p == "scissors" and c == "paper": | |
print("You win") | |
elif p == "paper" and c == "rock": | |
print("You win") | |
elif p == "rock" and c == "scissors": | |
print("You win") | |
elif p == "paper" and c == "scissors": | |
print("I win") | |
elif p == "rock" and c == "paper": | |
print("I win") | |
elif p == "scissors" and c == "rock": | |
print("I win") | |
while not(c == p): | |
quit() | |
rps() |