online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
import time import random import os def clear_screen(): # Check if the operating system is Windows if os.name == 'nt': os.system('cls') # For Windows else: os.system('clear') # For other platforms like macOS and Linux # MATCHES USERS MENU SELECTION TO ROCK, PAPER, OR SCISSOR # THEN CALLS COMPUTER SELECTION FOR MATCH UP AND BATTLE def match(user_selection): user_selection -= 1 if user_selection == 3: exit() print(' YOU:\n', tool[user_selection], '\nVS', end='') for _ in range(4): print('.', end='') time.sleep(1) computer_play(user_selection) def computer_play(user): comp = random.randint(0, 2) print('\n COMPUTER: \n', tool[comp]) battle(user, comp) def battle(user, comp): global user_score, computer_score # ROCK = 0 : PAPER = 1 : SCISSOR = 2 print(user, ' ', comp) if user == comp: print("You are tied") elif user + 2 == comp or user - 1 == comp: print(f'You WIN. {rck_ppr_scssr[user].upper()} beats {rck_ppr_scssr[comp].upper()}') user_score += 1 else: print(f'Computer WINS. {rck_ppr_scssr[comp].upper()} beats {rck_ppr_scssr[user].upper()}') computer_score += 1 print(f'Score: \n You: {user_score} \n Computer: {computer_score}') def main_menu(): while True: try: clear_screen() print(' ' * 40, 'Rock Paper Scissor\n') print('Enter your selection: \n1. Rock \n2. Paper \n3. Scissor\n4. Quit \n') user_selection = int(input(': ')) if user_selection not in range(1, 5): clear_screen() print('Select a number between 1 and 4') input('Press ENTER to continue ') continue break except: clear_screen() print('Please enter only digits') input('Press ENTER to continue ') continue match(user_selection) # ______________MAIN BODY _________________ go_again = 'y' rck_ppr_scssr = ('rock', 'paper', 'scissor') tool = ['ROCK', 'PAPER', 'SCISSOR'] user_score = 0 computer_score = 0 # THIS IS FOR FILES I CREATED WITH ASCII ART. FOR SIMPLICITY I JUST CREATED THE # tool [] LIST IN ITS PLACE #for x in rck_ppr_scssr: # f = open(f'{x}.x', 'r') # tool.append(f.read()) # f.close() while go_again in ['y', 'yes']: main_menu() go_again = input('Keep playing? (Y/N): ').lower()

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