### Thread: Continuing developing the number game!

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2013
Posts
5
Rep Power
0

#### Continuing developing the number game!

I know this is simple code, but as I work through tutorials I am trying to add advancements to it. I can't get a section of this code to work:
Code:
```print("Try to guess the number!  It's between 1 and 100!")
x = int(input())
while True:  #this section is supposed to foolproof the input so that if it's not an integer it asks for another input..  But it doesn't work.
if type(x) != int:
print("It must be a number!  Guess again!")
x = int(input())
elif type(x) == int:
break
import random
y = random.randint(1, 100)
while True:
if x > y:
print("Too high!  Guess again!")
x = int(input())
elif x < y:
print("Too low!  Guess again!")
x = int(input())
else:
print("Noooo!  You beat me!  You were never supposed to win! :(")
break```
It is mentioned in a comment. I was attempting to ensure the input was in fact a number so that if someone who did not no better could not create and error by putting a letter. Thanks!
Code:
```print("Try to guess the number!  It's between 1 and 100!")
x = int(input())   ##########PROBLEM OCCURS HERE
while True:  ###############YOU CHECK FOR TROUBLE TOO LATE THE PROBLEM ALREADY OCCURRED.
if type(x) != int:
print("It must be a number!  Guess again!")
x = int(input())
elif type(x) == int:
break```

string_in = input()

try: x = int(string_in)
except: print('Enter a dang number')

And furthermore, python tells you the line number where of the problem. Read the trace back error messages. Understand them.