Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions