Skip to content

Instantly share code, notes, and snippets.

@carlvanwormer
Created January 14, 2025 17:58
Show Gist options
  • Save carlvanwormer/e9bd4c41f151c00d6671319f3cd1b641 to your computer and use it in GitHub Desktop.
Save carlvanwormer/e9bd4c41f151c00d6671319f3cd1b641 to your computer and use it in GitHub Desktop.
# 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