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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Maor Beeri](https://uploads.teamtreehouse.com/production/profile-photos/8369252/micro_IMG_3239.jpg)
Maor Beeri
2,154 PointsNeed help with input issue
when the user enters something other than a number (for example the char 'g') as an input the program does not know how to handle this case properly. despite this code line that supposed to handle such a case:
except ValueError:
print("{} is not a number".format(guess))
output example:
Guess a number between 1 and 10: 5
my number is greater than 5
Guess a number between 1 and 10: y
5 is not a number
2 Answers
![Majid Bilal](https://secure.gravatar.com/avatar/691bdaa5cc371cbbe8b6cd6351da017a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Majid Bilal
3,558 PointsYou can handle it by writing it this way:
number = input("Enter a Number: ")
try:
int(number)
except ValueError:
print('{} is not a number'.format(number))
![Majid Bilal](https://secure.gravatar.com/avatar/691bdaa5cc371cbbe8b6cd6351da017a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Majid Bilal
3,558 PointsI think you're converting the input to an integer and y never gets converted to an integer and never gets assigned to "guess" that's why it's not handling it as you'd like.
![Maor Beeri](https://uploads.teamtreehouse.com/production/profile-photos/8369252/micro_IMG_3239.jpg)
Maor Beeri
2,154 PointsI'm sure this is the issue obviously but how do I fix this bug?