Skip to content

Instantly share code, notes, and snippets.

@Jadens-arc
Last active September 28, 2019 01:52
Show Gist options
  • Save Jadens-arc/9d53ac51061b21d9f55501a1668380be to your computer and use it in GitHub Desktop.
Save Jadens-arc/9d53ac51061b21d9f55501a1668380be to your computer and use it in GitHub Desktop.
A dice simulator in python
import random, os
'''
run using python3 dice.py in terminal
made by Jaden Arceneaux
'''
dice = []
total = 0
def addDie():
global total
print('how many sides does your die have')
dieSides = int(input())
dice.append(dieSides)
def roll():
global total, dice
for die in dice:
rolled = random.randint(0, die)
print('die numeber ' + str(dice.index(die) + 1) + ' rolled: ' + str(rolled))
total += rolled
print('total: ' + str(total))
total = 0
dice = []
while True:
for die in dice:
print(str(die) + ' sided die')
print('\nadd die\nroll\nquit')
userIn = input().lower()
if 'add die' in userIn:
addDie()
os.system('clear')
continue
elif 'roll' in userIn:
roll()
continue
elif 'quit' in userIn:
os.system('clear')
break
else:
print('not in system')
continue
print('bye \n -Jaden')
# ps I did it ismael
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment