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

I am on Lesson 2 of MIT 6.00. Anytime I type an "if", it won't let me type the "else"

OpenStudy (anonymous):

how do you mean? Is it giving you an error? Are you remembering the colon at the end of the if statement? ex: if x > 2:

OpenStudy (anonymous):

I'm completely new to this, so let me give a little background info... I'm running Lion on my MacBook Pro. I installed Macports and Xcode. I open Terminal, and then type Python and press enter. When I enter this in: x = 15 if (x/2)*2 == x: print 'Even' else: print 'Odd' After I hit "Enter" (having gotten to the "print 'Even' part) it gives me this error: File "<stdin>", line 2 print 'Even' ^ IndentationError: expected an indented block

OpenStudy (anonymous):

hmmm, not sure about it in terminal, I use IDLE (another python shell, that sounds like it works the same as you're doing in terminal). does it indent automatically for you after you hit enter after the if statement line? If not, are you hitting tab or several space bars? I ran into a problem like this yesterday where I was copy/pasting some of my stuff around and it read an indent as several spaces instead of a tab and gave me a similar error.

OpenStudy (anonymous):

is IDLE available for Mac?

OpenStudy (anonymous):

yeah, it was included with my download of python from the python.org website

OpenStudy (anonymous):

I just figured it out... Where's the "run" button... haha? I've got it set up, now need to run the program

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!