What is my error here?


I am missing something that outputs this code wrong. I have the SYNTAX messed up somewhere…

"""This code is a test of my knowledge!"""
Sandwich = 17
Butter = 50
Condom = 49
if Sandwich == Condom
	print "This should be the wrong response."
	else print "This should be the valid response to the code at hand."


you have an indent issue. else should have the same indent level as if


Could you correct it and show me, I am confused as heck! D;


understanding indent(ion) is crucial in python, given it determines nesting (what is nested in if clause for example):

if True:
    print "i am nested inside the if clause"

print "i am nested outside the if clause"

you nested your else inside your if clause, which causes problem, given else needs to be outside/after your if clause, given it needs to run when if evaluates to false


Okay, haven’t got to that part of the Python training just yet. Thank you anyway!!! You’re a big help.


you use if and else, to use them, you must understand indent(ion), see the docs:



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.