dice is a variable in a function not included in this code but it generates a list of 5 random numbers between 1 and 6. the function below i am trying to implement so that the user can choose which index in the list they want to change using an input. and taking the input from the user it changes those index's in the list with new random numbers between 1 and 6. ive tried it below but it is a very lengthy process, is there another way?
def reroll(dice):
rollagain = str(input("Which dice would you like to re-roll, input in ascending order (options are: 1,2,3,4,5): "))
if rollagain == '1,2,3,4,5':
dice[0, 1, 2, 3, 4].append = [randint(1, 6)]
return True
elif rollagain == '1,2,3,4':
dice[0, 1, 2, 3].append = [randint(1, 6)]
return True
elif rollagain == '1,2,3':
dice[0, 1, 2].append = [randint(1, 6)]
return True
elif rollagain == '1,2':
dice[0, 1].append = [randint(1, 6)]
return True
elif rollagain == '1':
dice[0].append = [randint(1, 6)]
return True
elif rollagain == '1,3,5':
dice[0, 2, 4].append = [randint(1, 6)]
return True
elif rollagain == '2, 4':
dice[1, 3].append = [randint(1, 6)]
return True
elif rollagain == '2':
dice[1].append = [randint(1, 6)]
return True
elif rollagain == '3':
dice[2].append = [randint(1, 6)]
return True
elif rollagain == '4':
dice[3].append = [randint(1, 6)]
return True
elif rollagain == '5':
dice[4].append = [randint(1, 6)]
return True
elif rollagain == '1,4,5':
dice[0, 3, 4].append = [randint(1, 6)]
return True
elif rollagain == '1,2,5':
dice[0, 1, 4].append = [randint(1, 6)]
return True
else:
return False