Python Forum
simple dice roll - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: simple dice roll (/thread-16937.html)



simple dice roll - Byzas - Mar-20-2019

Hi all,

Very new to programming.

Could anyone say how to point user input to dice value not dice number, I got this far:

import random

current_score = 0

dice1 = random.randrange(1,7)
dice2 = random.randrange(1,7)
dice3 = random.randrange(1,7)
dice4 = random.randrange(1,7)
dice5 = random.randrange(1,7)
all_dice = dice1, dice2, dice3, dice4, dice5 
print("Your dice:", dice1, dice2, dice3, dice4, dice5)
print()
all_dice1 = str(all_dice)
user_input = input("Dice:")
user_input = str(all_dice)[0:4]


print(user_input)
Thanks


RE: simple dice roll - ichabod801 - Mar-21-2019

If they give the value showing on the die (note that die is the singular of dice), you can find the first die with that value with all_dice.index(value).