0

For right now, I have it so it will print the random number it chose. However, whether I get it wrong or right it always says I am wrong.

here is my code:

import random

amount_right = 0
number = random.randint(1, 2)
guess = input
print(number)

print(
    "welcome to this number guessing game!! I am going to think of a number from 1-10 and you have to guess it! Good luck!")

input("enter your guess here! ")

if guess != number:
    print("Not quite!")
    amount_right -= 1
    print("you have a score of ", amount_right)

else:
    print("good Job!!")
    amount_right += 1
    print("you have a score of ",amount_right,"!")

what did I do wrong? I am using Pycharm if that helps with anything.

I tried checking my indentation, I tried switching which lines were the if and else statements (lines 13 - 21) and, I tried changing lines 18 - 21 to elif: statements

Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44

1 Answers1

1
guess = int(input())

You need to convert your guess to int and there should be () in input

Also there are 2 input() in your code. One is unnecessary. This can be the code.

import random

amount_right = 0
number = random.randint(1, 2)
print(number)

print(
    "welcome to this number guessing game!! I am going to think of a number from 1-10 and you have to guess it! Good luck!")

guess = int(input("enter your guess here! "))

if guess != number:
    print("Not quite!")
    amount_right -= 1
    print("you have a score of ", amount_right)

else:
    print("good Job!!")
    amount_right += 1
    print("you have a score of ",amount_right,"!")
Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44
  • In [How to Answer](https://stackoverflow.com/help/how-to-answer), note the section _Answer Well-Asked Questions_, and the bullet point therein regarding questions "that have been asked and answered many times before". – Charles Duffy Jan 21 '23 at 17:42