Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #Exercise 4 continue, break, pass
  2. #import packages
  3. import random
  4.  
  5. #list of options
  6. options = ["r", "p", "s"]
  7. rules = {"r": "s", "s": "p", "p" : "r"}
  8.  
  9. cPoints = 0
  10. pPoints = 0
  11.  
  12. #player = false
  13.  
  14. while cPoints < 3 or pPoints < 3 :
  15. player = input("r, p, s")
  16. computer = random.choice(options)
  17. if player == computer :
  18. print (f'Player between {pPoints} and {cPoints}')
  19. elif rules[player] == computer :
  20. print (f'player won: player {pPoints} and computer {cPoints}')
  21. pPoints +=1
  22. else :
  23. print (f'computer won: player {pPoints} and computer {cPoints}')
  24. cPoints +=1
  25.  
  26. print(f' {pPoints}, {pPoints}')
  27.  
  28. if cPoints > pPoints :
  29. print("Computer won")
  30. else :
  31. print("Player won")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement