Q:

python checking user input for number in a while loop

I have a function below which is part of my big main function, what I want this function to do is that whenever called, I want the function to check if the user input is 
a number or not. If it is a number it will return the number and break.
But if it is not a number I want it to loop again and again.when I try to 
run it, it gives me unexpected an error: 
unexpected eof while parsing 

can any body help me what I am missing or how I should rearrange my code? thank you!
def getnumber():
    keepgoing==True
    while keepgoing:
        number = input("input number: ") 
        result1 = number.isdigit()

        if result1 == 1:
            return number
            break
        elif keepgoing==True:

A:

A neater and clearer what to do what you are already doing:
def getnumber():
    while True:
        number = input("Input number: ")
        if number.isdigit():
            return number

That's all you need, the extra variables are superfluous and the elif at the end makes no sense. You don't need to check booleans with == True or == 1, you just do if condition:. And nothing happens after return, your break will never be reached. 

