Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from random import randint
- #create a list of play options
- t = ["rock", "paper", "scissors"]
- comp_wins = 0
- player_wins = 0
- while True:
- player = input("Rock, paper, scissors? ")
- computer = t[randint(0,2)]
- if player == computer:
- print("Computer chose: " + computer)
- print("Tie!")
- elif player == "rock":
- if computer == "paper":
- print("Computer chose: " + computer)
- print("You lose!")
- comp_wins += 1
- else:
- print("Computer chose: " + computer)
- print("You win!")
- player_wins += 1
- elif player == "paper":
- if computer == "scissors":
- print("Computer chose: " + computer)
- print("You lose")
- comp_wins += 1
- else:
- print("Computer chose: " + computer)
- print("You win!")
- player_wins += 1
- elif player == "scissors":
- if computer == "rock":
- print("Computer chose: " + computer)
- print("You lose!")
- comp_wins += 1
- else:
- print("Computer chose: " + computer)
- print("You win!")
- player_wins += 1
- else:
- print("Not a valid entry")
- if player_wins == 3:
- print("You win the match")
- break
- if comp_wins == 3:
- print("The computer wins the match")
- break
- if player_wins == 2 and comp_wins == 0:
- print("You win the match")
- break
- if comp_wins == 2 and player_wins == 0:
- print("The computer wins the match")
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement