online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
# Author Evan Arias from BlackJack_art import logo import random import os cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] def clear_console(): # For Windows if os.name == 'nt': os.system('cls') # For macOS and Linux else: os.system('clear') def deal_card(): return random.choice(cards) def calculate_score(cardz): score = sum(cardz) if score == 21 and len(cardz) == 2: return 0 if 11 in cardz and score > 21: cardz.remove(11) cardz.append(1) score = sum(cardz) return score def compare(user_score, computer_score): if user_score == 0 and computer_score == 0: return "It's a draw! Both players have Blackjack!" elif user_score == 0: return "You win with a Blackjack!" elif computer_score == 0: return "Lose, opponent has Blackjack!" elif user_score == computer_score: return "Draw!" elif user_score > 21: return "You bust, Computer wins!" elif computer_score > 21: return "Computer busts, You win!" elif user_score > computer_score: return "You win!" else: return "Computer Wins!" end = False while not end: start = input("Do you want to play a game of Blackjack? Type 'y' or 'n': ").lower() if start == "y": clear_console() user_cards = [] computer_cards = [] users_choice = True print(logo) for card in range(2): user_cards.append(deal_card()) computer_cards.append(deal_card()) user_score = calculate_score(user_cards) computer_score = calculate_score(computer_cards) print(f" Your cards: {user_cards}, current score: {user_score} ") print(f" Computer's first card: {computer_cards[0]}") if user_score == 0 or computer_score == 0: outcome = compare(user_score, computer_score) print(outcome) else: while users_choice and user_score <= 21: hit_or_stay = input("Type 'hit' to get hit, type 'stay' to stay: ").lower() if hit_or_stay == "hit": user_cards.append(deal_card()) user_score = calculate_score(user_cards) print(f" Your cards: {user_cards}, current score: {user_score} ") print(f" Computer's first card: {computer_cards[0]}") elif hit_or_stay == "stay": while computer_score < 17: computer_cards.append(deal_card()) computer_score = calculate_score(computer_cards) break users_choice = False else: print("Invalid input. Please Try Again!") print(f" Your final hand: {user_cards}, final score: {user_score}") print(f" Computer's final hand: {computer_cards}, final score: {computer_score}") outcome = compare(user_score, computer_score) print(outcome) elif start == "n": end = True
logo = """ .------. _ _ _ _ _ |A_ _ |. | | | | | | (_) | | |( \/ ).-----. | |__ | | __ _ ___| | ___ __ _ ___| | __ | \ /|K /\ | | '_ \| |/ _` |/ __| |/ / |/ _` |/ __| |/ / | \/ | / \ | | |_) | | (_| | (__| <| | (_| | (__| < `-----| \ / | |_.__/|_|\__,_|\___|_|\_\ |\__,_|\___|_|\_\\ | \/ K| _/ | `------' |__/ """

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue