Question: Need help with Python: A game where there is a pile of sticks. The pile consists of 7 sticks. There are 2 users who go
Need help with Python:
A game where there is a pile of sticks.
The pile consists of 7 sticks.
There are 2 users who go back and forth picking a number and the amount of sticks decreases and updates.
I have all of this figured out:
pile_size = 7
print('Player', player_ID, 'moves next') player_ID = 1
print('Pile has', pile_size, 'sticks')
sticks_taken = int(input('Take how many sticks? '))
if sticks_taken > pile_size: print('Too many! There are only', pile_size, 'sticks!') continue
pile_size -= sticks_taken
if pile_size == 0:
print('Player', player_ID, 'loses!') break
However, I cannot do the code to add 2 more piles of sticks.
pile1 = 7
pile2 = 7
pile3 = 7
pile = int(input('Which pile? ')) How do I add mutliple piles so the users can chose which pile then chose the number of sticks? Please help fix this code so that there are 3 piles of 7 instead of 1 pile of 7.
I am confused how the user can select the pile and take sticks ONLY from that pile.
Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
