Ok, so I am following along in lecture 2 and like to write the same code that I see the instructor writing to make sure I understand every individual part of it. He is currently explaining how to use conditional commands such as "if" and else". When I write this code x = 15 if (x/2)*2 == x: print 'Even' else: print 'Odd' into IDLE, it returns with a syntax error and highlights the end quotation mark on Even (so this one 'Even'<--) Also: On the instructor's screen, the "print" commands show up as orange, whereas mine are showing up as purple. What is going on here? Ok, so I am following along in lecture 2 and like to write the same code that I see the instructor writing to make sure I understand every individual part of it. He is currently explaining how to use conditional commands such as "if" and else". When I write this code x = 15 if (x/2)*2 == x: print 'Even' else: print 'Odd' into IDLE, it returns with a syntax error and highlights the end quotation mark on Even (so this one 'Even'<--) Also: On the instructor's screen, the "print" commands show up as orange, whereas mine are showing up as purple. What is going on here? @MIT 6.00 Intro C
What version of Python are you running? If you're using v3 the print function doesn't work the same as in version 2.x (this course was designed using 2.5 I believe...)
I'm using v3.2.2
I highly recommend getting v2.7 for this course. Read this for info on changes in v3: http://docs.python.org/release/3.0.1/whatsnew/3.0.html#print-is-a-function
Strongly agree with seanlerner. Make life easier & get the same version they used in the class.
Thanks a lot for the help both of you :). I will change versions and see if my error still occurs.
Just tried it out and it works. Thanks so much :D
Join our real-time social learning platform and learn together with your friends!