0

game_2 is = 34 but changes when the input from guess, how do i keep it as 34?? as it keeps saying error how do i make this more readable and is there anything i can do to not make the input change the answer?

my_name = 'shaun'
yourname = input('what is your name? ')
print('nice to meet you', yourname, 'i am', my_name)
play_game = input('do you want to play a game? ')
if play_game == 'yes':
    print('okay lets play a game')
else:
    print('okay, bye then')
    quit()
game = input(f'if you can tell me how old you are, i have to work out how many months that is, and then its your turn to do it to me... okay ' + yourname +"? ")
if game == 'yes' or 'okay' or 'go on then' or 'yeah':
    print('okay, how old are you in years? ')
    age = int(input())
    answer = age * 12
    print("that's way to easy ", answer)
    game_2 = 34
    guess = input('guess my age, i will give you a clue, i am 408 months old ')
    if guess == game_2:
        print("wow!! you're a wizard! " + yourname)
    else:
        print('no, try again ' + yourname)
        input()
        print("nope, not even close")
        input()
        print('come on, are you even trying?, last go ')
        input()
        print(' my age was 34 okay maybe this is to ward for you, shall we try another game?')
coder1996
  • 9
  • 4
  • 3
    input returns string. either make game_2 = "34" or cast your input into int –  May 09 '22 at 12:50
  • 3
    `input()` returns a string, you did it correctly here: `age = int(input())`, but not on `guess = input('guess ...')` – ivvija May 09 '22 at 12:50
  • 2
    I've tried to fix the formatting, but might have messed up the indentation and since this is python: please check that this is still what you meant, coder1996. – Joachim Sauer May 09 '22 at 12:51
  • 2
    `game == 'yes' or 'okay' or 'go on then' or 'yeah'` is not what you intended (always evaluates to `*okay'` which is truthy); use `game in {'yes', 'okay', 'go on then', 'yeah'}` instead to check whether the user chose one of your options. – Luatic May 09 '22 at 12:54
  • @SembeiNorimaki hi, i did this but didnt work – coder1996 May 09 '22 at 13:24
  • @coder1996 what did you do and how did it not work? –  May 09 '22 at 13:57

0 Answers0