import time import random print("----------------------------") print("Coinflip") print("") coins = 10 while True: print("You have " + str(coins) + " coins.") choice = input("Choose heads or tails: ").lower() if choice != "heads" and choice != "tails": print("Invalid choice. Please choose heads or tails.") continue bet = int(input("Enter the amount to bet: ")) if bet <= 0 or bet > coins: print("Invalid bet amount.") continue coin_flip = random.choice(["heads", "tails"]) print("Flipping the coin...") time.sleep(1) print("The result is " + coin_flip + "!") if coin_flip == choice: print("Congratulations! You win " + str(bet) + " coins.") coins += bet else: print("Sorry, you lose " + str(bet) + " coins.") coins -= bet print("") if coins >= 1000: print("Pls dont play anymore or we will be out of money.") if coins <= 0: print("You have run out of coins. Game over.") break play_again = input("Do you want to play again? (yes/no): ").lower() if play_again != "yes": print("Thank you for playing!") break print("")