Hey, so i am trying to build a game of the goose game. When you roll a dice you get some values. And at one point, i will need the value to decrease. Lets say, if the value reaches 10, it has to decrease from that point.
Like lets say the current value is 8, we get a 5 from the dice, then the interaction should look like this:
9
10
9
8
7
But in my code, it keeps doing this:
9
10
9
10
9.
here is the code:
while True:
dice_1 = random.randint(1, 6)
dice_2 = random.randint(1, 6)
dice = dice_1 + dice_2
b = input("Stop or continue?\n")
for a in range(dice):
while position_1 < 10:
position_1 += 1
positions_1.append(position_1)
if position_1 > 10:
excess = position_1 - 10
position_1 = 10 - excess
positions_1.append(position_1)
if b == "continue":
for pos in positions_1[len(positions_1)-dice:]:
if pos == position_1:
print(f"{pos} player_1")
else:
print(pos)
elif b == "stop":
break
if dice_1 != dice_2:
break
print("You get another turn, lucky!!")
there is a code that does what I want, but I still cant fix the original code.
here is the code that works:
import random
import time
b = 10
while True:
a = int(input("add a number:" ))
value = b + a
if value > 20:
steps = 20 - b
for i in range(steps):
b += 1
print(b)
time.sleep(0.3)
excess = (value) - 20
for i in range(excess):
b -= 1
print(b)
time.sleep(0.3)
else:
for i in range(a):
b += 1
print(b)
if b == 20:
break
any help would be appreciated. This has been bugging me for 2 days. Thanks already