Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Exercise 4 continue, break, pass
- #import packages
- import random
- #list of options
- options = ["r", "p", "s"]
- rules = {"r": "s", "s": "p", "p" : "r"}
- cPoints = 0
- pPoints = 0
- #player = false
- while cPoints < 3 or pPoints < 3 :
- player = input("r, p, s")
- computer = random.choice(options)
- if player == computer :
- print (f'Player between {pPoints} and {cPoints}')
- elif rules[player] == computer :
- print (f'player won: player {pPoints} and computer {cPoints}')
- pPoints +=1
- else :
- print (f'computer won: player {pPoints} and computer {cPoints}')
- cPoints +=1
- print(f' {pPoints}, {pPoints}')
- if cPoints > pPoints :
- print("Computer won")
- else :
- print("Player won")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement