In the board game monopoly, a player tosses two dices together and the sum of the two dices

points is the number of steps he or she should go. For example a player gets a 2 and a 3, then
he or she should go 5 steps forward. If the two dices give the same number (for example two
2), which is called a “double”, after moving forward (4 steps), the player gets another chance to
toss and move forward again. However, if someone tosses 3 consecutive doubles, he or she will
be sent to jail.
Consider that you are tossing two fair dices for many times. You won’t stop until you get 3
doubles. After you stop, take down the number of tosses you use. Use a loop to repeat this at
least 1000 times. Calculate the average of the 1000 results, that is, how many tosses is needed
on average, to be able to get three consecutive doubles.

To calculate the average number of tosses needed to get three consecutive doubles in Monopoly, you can simulate the process using a loop and repeat it at least 1000 times. Here's how you can do it in Python:

1. Set up a loop that runs 1000 times.
2. Inside the loop, initialize a counter variable to keep track of the number of tosses needed.
3. Use another loop to simulate the dice tosses until three consecutive doubles are rolled.
4. In each iteration of the inner loop, generate two random numbers between 1 and 6 to represent the dice rolls.
5. Check if the two dice rolls are the same (a double).
6. If it's a double, increment a consecutive count variable and move forward 4 steps.
7. If it's not a double, reset the consecutive count to 0 and move forward only the number of steps based on the dice sum.
8. Increment the toss counter by 1 for each toss.
9. Once the consecutive count reaches 3, break out of the inner loop.
10. After the loop finishes, store the toss counter for that iteration in a list.
11. Finally, calculate the average of the toss counts from the list.

Here's a sample Python code that implements the steps described above:

```python
import random

toss_counts = [] # A list to store the toss counts

for _ in range(1000):
toss_counter = 0
consecutive_count = 0

while consecutive_count < 3:
dice1 = random.randint(1, 6)
dice2 = random.randint(1, 6)
toss_counter += 1

if dice1 == dice2:
consecutive_count += 1
dice_sum = 4 # Move forward 4 steps after a double
else:
consecutive_count = 0
dice_sum = dice1 + dice2

# You can print the dice rolls and sums if you want to see the individual results
# print(f"Dice 1: {dice1}, Dice 2: {dice2}, Sum: {dice_sum}")

toss_counts.append(toss_counter)

average_tosses = sum(toss_counts) / len(toss_counts)
print(f"Average number of tosses needed: {average_tosses}")
```

By running this code, you will get the average number of tosses needed to get three consecutive doubles in Monopoly after simulating the process 1000 times.