Need help with this! Uses a while counter loop

In front of you is a non-see through bag containing 50 red balls and 50 black balls. You are to design a solution that will allow you to draw one ball at a time until 12 red balls are drawn. At the end of the program you will display a message stating how many balls were drawn and how many of them were black.

Sure! Here's an example solution using a while loop in Python:

```python
red_balls = 0
black_balls = 0
total_balls_drawn = 0

while red_balls < 12:
ball = random.choice(['red', 'black']) # Assuming you have imported the random module

if ball == 'red':
red_balls += 1
else:
black_balls += 1

total_balls_drawn += 1

print("Balls drawn:", total_balls_drawn)
print("Black balls drawn:", black_balls)
```

Explanation:

1. Initialize the counters `red_balls`, `black_balls`, and `total_balls_drawn` to 0.

2. Enter the while loop as long as the number of red balls drawn (`red_balls`) is less than 12.

3. Inside the loop, use the `random.choice()` function to randomly select either 'red' or 'black' from the given choices.

4. If the ball drawn is 'red', increment the `red_balls` counter by 1. Otherwise, increment the `black_balls` counter by 1.

5. Increment the `total_balls_drawn` counter by 1 after each ball is drawn.

6. Repeat steps 3 to 5 until 12 red balls are drawn.

7. Once the loop finishes (12 red balls are drawn), display the total number of balls drawn (`total_balls_drawn`) and the number of black balls drawn (`black_balls`) using the print statement.

Note: Don't forget to import the `random` module if you haven't already.