← Back to all posts
Help me with this BNGG (BRUTAL NUMBER GUESSING GAME!!!)

Anyways, here's the code

``````import replit
import random
import time

replit.clear()
def game():
print ("Generating...")
num = random.randrange(1,1001)
time.sleep(2)

print ("OK! You have 1 guess and the number you have to guess is between 1 and 1000 (including 1 and 1000)")
time.sleep(1)
print ("1.semi-god (1 guess)")
print ("2.normal mode (10 guesses)")
print ("3.shy guy (50 guesses)")
gamemode = input("")

if gamemode == "1":
nump = input(">")
time.sleep(0.5)
if nump == num:
print ("That's right! You win!")
time.sleep(1)
game()
print ("Click Run again to play again!")
elif gamemode == "2":
for guess in range(1,11):
print ("Guess %d"% guess)
nump = input(">")
time.sleep(0.5)
if nump == num:
print ("WOW! That's right pal!")
time.sleep(1)
game()
guess = guess + 1
print ("Out of guesses")
print ("Click Run to play again!")
elif gamemode == "3":
print (num)
for shyer in range(1,51):
print ("Guess %d"% shyer)
nump = input(">")
time.sleep(0.5)
if nump == num:
print ("That's pretty good for a shyer (jk, not meaning to be mean, ok?)")
time.sleep(1)
game()
shyer = shyer + 1
print ("Out of guesses")
print ("Click Run to play again!")

game()``````

So, the if statements on line 22,31 and 45 are not working even though they qualifies the condition (i tested those), if anyone know how to fix this, please help!

Answered by CaptainAnon (50) [earned 5 cycles]
The python `input()` function by default returns a string. Because python cannot compare strings to integers you need to convert the value returned by the input function to an integer, so `nump = int(input(">"))`.