0
def func(val):
    num = int(input("Enter a number:"))
    if num>val: 
        print ("Too high!")
    return 1
    elif num: 
        print ("Too low!")
    return -1
    else: 
        print ("Got it!!")
    return 0
        ch=1
    while(ch!=0): 
        ch=func(15)

I keep getting the error: "elif num: ^ SyntaxError: invalid syntax" Is it simply a formatting issue that is causing this error message? or my code?

1
  • All your returns are incorrectly indented. Commented Apr 30, 2020 at 19:05

1 Answer 1

2

return statements should be indented

def func(val):
    num = int(input("Enter a number:"))
    if num>val: 
        print ("Too high!")
        return 1
    elif num: 
        print ("Too low!")
        return -1
    else: 
        print ("Got it!!")
        return 0
        ch=1
    while(ch!=0): 
        ch=func(15)
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I can get it to run now, but there is no output to ask me to enter a number?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.