Created
May 17, 2020 14:38
-
-
Save dashdanw/7a5c1db5407886bd77f2ce5d87aac52d to your computer and use it in GitHub Desktop.
weird yahtzee game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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