Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Number Game App Number Game Introduction

srikanth soma
srikanth soma
1,572 Points

guess number not working correctly

import random
secret_number = random.randint(1, 10)
print(secret_number)
while True:
    guess_number = input("Enter a number between 1 and 10: ")
    if guess_number == secret_number:
        print("You got it! my secret number was {}".format(secret_number))
        break
    else:
        print("That's not it")
srikanth soma
srikanth soma
1,572 Points

Even my guess number is equals to my secret number app still runs and it doesn't quit what wrong did I make? I'm running the above code in pycharm.

2 Answers

Stuart Wright
Stuart Wright
41,118 Points

Looks like guess_number will always be a string and secret_number is an integer - that's why they're never equal. You can convert guess_number to an integer using the int() function.