Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

elif syntax error

+4 votes
asked Nov 4, 2021 by Princess (170 points)
I am using an elif statement and it is giving me a syntax error. Why is that?

2 Answers

+2 votes
answered Nov 5, 2021 by 1221 Swetha (190 points)
we should write conditions for if and elif along with the indentation (indentation gap should be equal for every  statement)

if(condition):

    statements

elif(condition):

    statements

else:

    statements
+3 votes
answered Nov 5, 2021 by Peter Minarik (84,720 points)
Could you please share your code?

Probably you missed something (e.g. a colon).
commented Nov 12, 2021 by Princess (170 points)
commented Nov 12, 2021 by Peter Minarik (84,720 points)
There are colons missing from the end of the lines of if/else statements and also your indentation is wrong.

It's  fixed here: https://onlinegdb.com/vZhz8uXjc
commented Nov 12, 2021 by Princess (170 points)
thank you so much!
commented Nov 12, 2021 by Princess (170 points)
i dont mean to disturb you but I was also having an issue with running this code: https://onlinegdb.com/fhiflHgiB
commented Nov 13, 2021 by Peter Minarik (84,720 points)
You did not close one of the parentheses and had the commas on the left side of the quotation mark, but they should have gone to the right side.

Your code fixed is here: https://onlinegdb.com/JfMYt00G4
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...