diff --git a/README.md b/README.md index f63240e9..f2b875ad 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Steps to contribute in this repository - 1. Fork this repo + 1. Fork this repo 2. Propose/Update (C++/Java/Python) file of your choice 3. Add useful code for the open-source community 4. Make pull request diff --git a/rps.py b/rps.py new file mode 100644 index 00000000..231e2458 --- /dev/null +++ b/rps.py @@ -0,0 +1,36 @@ +from random import randint + +#create a list of play options +t = ["Rock", "Paper", "Scissors"] + +#assign a random play to the computer +computer = t[randint(0,2)] + +#set player to False +player = False + +while player == False: +#set player to True + player = input("Rock, Paper, Scissors?") + if player == computer: + print("Tie!") + elif player == "Rock": + if computer == "Paper": + print("You lose!", computer, "covers", player) + else: + print("You win!", player, "smashes", computer) + elif player == "Paper": + if computer == "Scissors": + print("You lose!", computer, "cut", player) + else: + print("You win!", player, "covers", computer) + elif player == "Scissors": + if computer == "Rock": + print("You lose...", computer, "smashes", player) + else: + print("You win!", player, "cut", computer) + else: + print("That's not a valid play. Check your spelling!") + #player was set to True, but we want it to be False so the loop continues + player = False + computer = t[randint(0,2)]