Created
January 14, 2025 17:58
-
-
Save carlvanwormer/e9bd4c41f151c00d6671319f3cd1b641 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# version 53 | |
import random | |
def roll_dice(): | |
return random.randint(1, 6), random.randint(1, 6) | |
def main(): | |
while True: | |
input("Press Enter to roll the dice...") | |
dice1, dice2 = roll_dice() | |
total = dice1 + dice2 | |
print(f"You rolled a {dice1} and a {dice2}. Total: {total}") | |
if total == 7 or total == 11: | |
print("You win!") | |
elif total in [2, 3, 12]: | |
print("Craps! You lose.") | |
else: | |
print("Roll again.") | |
play_again = input("Do you want to play again? (y/n): ").lower() | |
if play_again != 'y': | |
break | |
print("Thanks for playing!") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment