Skip to content

Instantly share code, notes, and snippets.

@dashdanw
Created May 17, 2020 14:38
Show Gist options
  • Save dashdanw/7a5c1db5407886bd77f2ce5d87aac52d to your computer and use it in GitHub Desktop.
Save dashdanw/7a5c1db5407886bd77f2ce5d87aac52d to your computer and use it in GitHub Desktop.
weird yahtzee game
#nice loop for input
dice_count=input("How many dices do you want to use? Min 1, max 5")
while not dice_count.isnumeric() or int(dice_count) not in range(1,5):
dice_count=input(f'Sorry, {dice_count} is not a number, please input a number between 1 and 5.')
dice_count = int(dice_count)
#declare an array of soon-to-be values that we will modify as we go
dice_states = ['<empty>']*dice_count
while '<empty>' in dice_states:
#removes one of the dice to roll
dice_states.remove('<empty>')
#generates the roll
dice_roll = randint(1,6)
print(f"roll: {dice_roll}")
if dice_roll == 1:
#append two empty rolls
dice_states += ['<empty>']*2
else:
dice_states.append(dice_roll)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment