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 trialsrikanth soma
1,572 Pointsguess 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")
2 Answers
Stuart Wright
41,120 PointsLooks 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.
srikanth soma
1,572 PointsThanks so much :)
srikanth soma
1,572 Pointssrikanth soma
1,572 PointsEven 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.