Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simple dice roll
#1
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
Reply
#2
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).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dice Roll (Find out how many rolls until specified streak) DustinKlent 4 3,913 Jun-13-2021, 09:44 AM
Last Post: Gribouillis
  Help with dice roll program kraco 4 2,043 Sep-22-2020, 02:06 PM
Last Post: kraco
Photo roll of the dice kyle007 0 1,695 Mar-11-2019, 01:58 AM
Last Post: kyle007
  unit test roll die saladgg 5 4,117 Nov-06-2018, 11:39 PM
Last Post: stullis
  Issue with my 'roll the dice simulation'-exercise (cannot break out of the loop) Placebo 2 3,465 Sep-30-2018, 01:19 PM
Last Post: Placebo
  Making a percentile dice roller and dice roller Fixer243 2 3,198 Sep-30-2018, 12:18 PM
Last Post: gruntfutuk
  Random Dice roll program th3h0bb5 1 5,512 Oct-18-2016, 09:25 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020