Skip to content

Instantly share code, notes, and snippets.

@Just-Simple-59
Last active June 26, 2021 07:03
Show Gist options
  • Save Just-Simple-59/d34c010cba1c53fb7544d4624dbb14ae to your computer and use it in GitHub Desktop.
Save Just-Simple-59/d34c010cba1c53fb7544d4624dbb14ae to your computer and use it in GitHub Desktop.
Make a player vs computer Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game)
def main():
import random
a = ["rock", "paper", "sissors"]
b = random.choice(a)
c = int(input("Enter your choice of play\n For ROCK enter 1\n For PAPER enter 2\n For SISSORS enter 3\n"))
if b == "rock" and c == 1:
print("It's a DRAW")
elif b == "rock" and c == 2:
print("Congratulation's, you won")
elif b == "rock" and c == 3:
print("Sorry, you lost")
elif b == "paper" and c == 1:
print("Sorry, you lost")
elif b == "paper" and c == 2:
print("It's a DRAW")
elif b == "paper" and c == 3:
print("Congratulation's, you won")
elif b == "sissors" and c == 1:
print("Congratulation's, you won")
elif b == "sissors" and c == 2:
print("Sorry, you lost")
elif b == "sissors" and c == 3:
print("It's a DRAW")
else:
print("you have selected a wrong input key")
print("Mine was " + b)
ask = str(input("Do you like to play again\n If yes enter 'y'\n If no enter 'n'\n"))
if ask.lower() == 'y':
main()
elif ask.lower() == 'n':
print("Thank you for playing")
else:
print("invalid input")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment