Sep-21-2020, 02:17 PM
Please help me with this dice roll program.
I am trying to make program witch checks for dice roll result and then writes a line, when an number was rolled write text see example under:
EXAMPLE Results: Dices Rolled : 2 This is a test
if dice 5 was rolled show text: My dad has a black car
I am stuck and cant figure it out, please help
Regards
Kraco
I am trying to make program witch checks for dice roll result and then writes a line, when an number was rolled write text see example under:
EXAMPLE Results: Dices Rolled : 2 This is a test
if dice 5 was rolled show text: My dad has a black car
I am stuck and cant figure it out, please help
Regards
Kraco
# to get random number from list # using random.randrange import random # initializing list Dice_list = [2, 3, 4, 5, 6, 7, 9, 10, 11, 12] # using random.randrange() to # get a random number rand_idx = random.randrange(len(Dice_list)) random_num = Dice_list[rand_idx] # printing random number print("Dices Rolled : " + str(random_num)) # EXAMPLE Results: Dices Rolled : 2 This is a testa # result dice number, print text: # if 2 or 3 was dice result, show dice number and print text this i a test if "2,3" in (str(random_num)): print('This is a test') #if 4 or 5 was dice result, show dice number and print text My dad has a black car if "4,5" in (str(random_num)): print('My dad has a black car') # if 6 or 7 or 8 was dice result, show dice number and print text My mother is from japan if "6,7,8" in (str(random_num)): print('My mother is from japan') #if 9 or 10 was dice result, show dice number and print text My father is from USA if "9,10" in (str(random_num)): print('My father is from USA') # if 11 or 12 was dice result, show dice number and print text My brother is from Sweden if "11,12" in (str(random_num)): print('My brother is from Sweden') #print("The string after adding number is : " + str(res))