clean up the dice stringdicestr dicestr lower(replace('''find the "din the dice string inputdindex dicestr find(' 'if dindex =- raise exception('missing the "dcharacter 'get the number of dice (the " in " + ")numberofdice dicestr[:dindexif not numberofdice isdecimal()raise exception('missing the number of dice 'numberofdice int(numberofdicefind if there is plus or minus sign for modifiermodindex dicestr find('+'if modindex =- modindex dicestr find('-'find the number of sides (the " in " + ")if modindex =- numberofsides dicestr[dindex :elsenumberofsides dicestr[dindex modindexif not numberofsides isdecimal()raise exception('missing the number of sides 'numberofsides int(numberofsidesfind the modifier amount (the " in " + ")if modindex =- modamount elsemodamount int(dicestr[modindex :]if dicestr[modindex='-'change the modification amount to negativemodamount -modamount simulate the dice rollsrolls [for in range(numberofdice)rollresult random randint( numberofsidesrolls append(rollresultdisplay the totalprint('total:'sum(rollsmodamount'(each die:'end=''display the individual rollsfor iroll in enumerate(rolls)rolls[istr(rollprint('join(rolls)end=''display the modifier amountif modamount ! modsign dicestr[modindexdice roller