Why am I getting a syntax error?
This seems to be right. But I get an error at print when I run it. Anyone know why?
myList = [1,2,3,4]
for index in range(len(myList)):
myList[index] += 1
Last edited by ManiacDan; July 2nd, 2012 at 12:32 PM.
Sorry python. It is an example from a book I'm using. Just seems not to work for some reason.
Originally Posted by E-Oreo
1. Use code tags. Python code listings are pretty much worthless without them.
2. You're probably trying to run your code on a python 3 interpreter, which is not compatible with python 2 (which is what your code is).
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
This is the version I'm using. Not sure if 2.7 is to new or not.
July 18th, 2012, 02:50 AM
Same problem i am facing also but still failed to get solution...