Close
Close

If else

   veenasoral

Why I keep getting invalid syntax error in python while using "else" function?

  • Post your code
    - Amit Kumar

Answers

  •   

    don’t forget the indent and colon in the syntax .

    let’s write a programme for testing if i>99 print “good” if i>80 and i<99 print “ok” else print “try hard”

    it is working on python 3.5.4,which i was using…..please leave a comment on the answer

    -------------------------------------------------------------------------------------------------------------------------------------------

    i=int(input(“enter the number”))

    if i>99:

       print(“good”)

    elif i>80:

       print(“ok”)

    else:

       print(“Try hard”)

     



  •    adamusa

    One of the causes is Missing colon (:): When using "if-else" statement in Python, make sure that after the condition of "if" statement there is a colon. mapquest directions west virginia



Ask Yours
Post Yours
Write your answer