Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 13 Online
OpenStudy (anonymous):

i have a slight hitch in a small piece of code consider a nested if else .....it is showing an error on the else line (which is within another else)......can somebody help me out with right syntax?

OpenStudy (turingtest):

you can't have an else without an if first consider using various combinations of if, elif (else if), and else in that order

OpenStudy (anonymous):

you might want to use proper blocks for nested ifs. for example if { if{ ... code. } else { } } else { } basically u need to understand you indentations. if you want to put a nested if in your if, u need to create a block with {} and add your nested if-else in there.

OpenStudy (anonymous):

to answer the question better it helps if you post the code. from the sound of how you worded it you have an if/else statement and then just an else statement nested within the first else? if so you need the pairing if statement also nested under the same first else statement like this: if: code else: code if: code else: code similar to what onyrock posted but im assuming your programming in python not c so you dont use the brackets

OpenStudy (anonymous):

ronin12 is right. better to post the code.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!