Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. n=int(input("How many marbles to start with? "))
  2.  
  3. p=n
  4. switch = 1
  5. while p > 0:
  6. if switch==1:
  7. a = int(input('Player #1, there are ' + str(p) + ' marbles left. How many marbles will you take? '))
  8. p = p - a
  9. switch = 0
  10. else:
  11. a = int(input('Player #2, there are ' + str(p) + ' marbles left. How many marbles will you take? '))
  12. p = p - a
  13. switch = 1
  14.  
  15. print('Player #' +str(switch +1)+', you took the last marble and have won!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement