Python dice rolling game, choosing how many dice to roll
I'm trying to create a code for this dice rolling game. You have to roll dice until you reach the goal. You roll the dice every turn, which adds to your total so far. You want to hit the goal value exactly, which is 21 by default. The user has to choose how many dice to roll each turn (between 1 and 5). You have to keep rolling dice until you either win by getting 21 or lose by overshooting it. I've come up with this so far, but it is not working properly https://code.sololearn.com/cOk85A6OBcTT/#py How can I make it run correctly? Hint: Make use of while loops to be able to continue as long as needed and try/except to avoid that the program dies after non-integer input. Edit: Fixed some stuff. Jayakrishnain, I did fix that line, but now the issue is that after you do the first dice roll (with the allowed being between 1-5), the second dice roll has no limits. How can I ensure the limits again? The second time you'd be able to chose 10 dice, which is not allowed.