Я новичок в программировании, и у меня есть задача, которую я не могу решить самостоятельно.
Задача состоит в том, чтобы создать программу, которая позволит вам решать, сколько кубиков бросить, от 1 до 5, с проверкой правильности ввода. После каждого броска будет отображаться число d ie и сумма на текущий момент. Если d ie выпадает 6, то он не включается в общую сумму, и вы получаете больше бросков. Вот где я застрял. Я хочу, чтобы моя программа перезапустила l oop, если d ie превращается в 6 и просто ad 2 переходит к sumDices и продолжает l oop, но я не могу заставить его работать.
вот мой код:
import random
numDices=0
total = 0
print("------------")
print("DICE ROLLING")
print("------------")
print()
exit=False
reset=False
while True:
while True:
numDices=int(input("How many dices to throw? (1-5) "))
if numDices<1 or numDices>5:
print("Wrong input, try again")
break
while True:
if reset==True:
break
for i in range(numDices):
dicesArray = list(range(numDices))
dicesArray[i] = random.randint(1, 6)
print(dicesArray[i])
total += dicesArray[i]
if dicesArray[i] == 1:
print("You rolled a one, the total is: ",str(total))
elif dicesArray[i] == 2:
print("You rolled a two, the total is: ",str(total))
elif dicesArray[i] == 3:
print("You rolled a three, the total is: ",str(total))
elif dicesArray[i] == 4:
print("You rolled a four, the total is: ",str(total))
elif dicesArray[i] == 5:
print("You rolled a five, the total is: ",str(total))
elif dicesArray[i] == 6:
total-=6
numDices+=2
print("You rolled a six, rolling two new dices")
reset=True
print("The total sum is",str(total),"with",numDices,"number of rolls.")
print()
restart=(input("Do you want to restart press Enter, to quit press 9. "))
if restart=="9":
exit=True
break
else:
print()
break
if exit==True:
break