Get the most out of your questions with IDNLearn.com's extensive resources. Ask anything and receive prompt, well-informed answers from our community of knowledgeable experts.
Sagot :
Answer:
def dice_roller():
# ask for first input
input1 = int(input("Enter the first roll: "))
# check if it's valid
while input1 < 1 or input1 > 6:
print("Invalid number")
# ask for new input if the previous was invalid
input1 = int(input("Enter the first roll: "))
# ask for second input
input2 = int(input("Enter the second roll: "))
# check if it's valid
while input2 < 1 or input2 > 6:
print("Invalid number")
# ask for new input if the previous was invalid
input2 = int(input("Enter the second roll: "))
# check of the numbers are the same
if input1 == input2:
print("You rolled the same numbers. Try again")
# if they are the same call this function again to get new numbers
dice_roller()
else:
# print how many spaces to advance
print("Advance", input1+input2, "spaces")
if __name__ == '__main__':
dice_roller()
Thank you for participating in our discussion. We value every contribution. Keep sharing knowledge and helping others find the answers they need. Let's create a dynamic and informative learning environment together. Thank you for choosing IDNLearn.com for your queries. We’re here to provide accurate answers, so visit us again soon.