-2

Here is my code if anyone can help then that would be greatly apricated.

import random

a = ["rock", "paper", "scissors"]

def game():
    while True:
        try:
            word = input('Enter rock, paper, or scissors: ')
            if word not in a:
                raise ValueError # this will send it to the print message and back to the input option
            break 
          
        except ValueError:
            print(" You must enter rock, paper, or scissors.")


    comp_draw = random.choice(a)
    print('The computer drew ' + comp_draw)

    if comp_draw == 'rock' and word =='rock':
        print('It was a tie')
    elif comp_draw == 'paper' and word =='paper':
        print('It was a tie')
    elif comp_draw == 'scissors' and word =='scissors':
        print('It was a tie')
    elif comp_draw == 'paper' and word =='rock':
        print('GAME OVER')
    elif comp_draw == 'rock' and word =='paper':
        print('you won!')
    elif comp_draw == 'rock' and word =='scissors':
        print('GAME OVER')
    elif comp_draw == 'scissors' and word =='rock':
        print('you won!')
    elif comp_draw == 'scissors' and word =='paper':
        print('GAME OVER')
    elif comp_draw == 'scissors' and word =='rock':
        print('you won!')


if __name__ == "__main__":
    game()
    while True:
        if input('Would you like to play_again? ') == 'yes':
            game()
        else:
          break
        
      font = 'Arial (sans-serif)' : 'normal' 
        'weight' : 'bold',
        'size'   : 99} 

This is how I've tried to change the font

font = 'Arial (sans-serif)' : 'normal' 
        'weight' : 'bold',
        'size'   : 99} 

This is the error message I've received

IndentationError: unindent does not match any outer indentation level on line 48 font = 'Arial (sans-serif)' : 'normal' ^ in main.py

UnholySheep
  • 3,967
  • 4
  • 19
  • 24
Nick
  • 9
  • 1
  • 2
    That entire part about `font` doesn't make much sense. All the code above looks like it will be executed in a terminal, you don't change the font of that through your code (and none of that `font` syntax is valid Python either) – UnholySheep Jan 30 '23 at 16:51
  • I don't think you can change the font / size of the text of a command window from python, but I know you can change the font/size of the text of a command window from the settings in that command window. Bold for linux can be found here: https://stackoverflow.com/questions/8924173/how-can-i-print-bold-text-in-python – Jacob Glik Jan 30 '23 at 16:51
  • 1
    Your `font` variable is improperly indented. If it's to be inside that while loop it will need a few more space characters to line up with the preceding two lines. If it's outside the while loop, then you need to remove a couple of spaces to make it line up with `while True:`. ALSO you are missing a squirrely bracket and a comma for your `font` dictionary: Instead: `font = {'Arial (sans-serif)': 'normal', 'weight': 'bold', 'size': 99} ` Although that variable's usefulness seems questionable. – JNevill Jan 30 '23 at 16:53

2 Answers2

0

For the code to work, you need to unindent font, add a comma after 'normal' and add an opening brace:

if __name__ == "__main__":
    game()
    while True:
        if input('Would you like to play_again? ') == 'yes':
            game()
        else:
          break
        
font = {'Arial (sans-serif)' : 'normal' ,
       'weight' : 'bold',
       'size'   : 99} 

However, you are not using the font variable so it won't change anything. As has been mentioned, if you are printing to the terminal you can't change the font in python.

Jacob Kearney
  • 391
  • 11
0

Unfortunately, there isn’t an easy way for changing the printed font and it’s size through Python. You can try changing the console font and size using the shell’s api, but this is very platform specific and isn’t easy to set up.

What you can do, is use a simple graphics library like pygame, where you can output graphics from your python application. You can check out this docs to learn how to use fonts in pygame.

JuliusB
  • 46
  • 4