#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    3
    Rep Power
    0

    Why am I getting a syntax error?


    Code:
    myList = [1,2,3,4]
    for index in range(len(myList)):
        myList[index] += 1
    print myList
    This seems to be right. But I get an error at print when I run it. Anyone know why?
    Last edited by ManiacDan; July 2nd, 2012 at 11:32 AM.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,301
    Rep Power
    7170
    What language is it?
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by E-Oreo
    What language is it?
    Sorry python. It is an example from a book I'm using. Just seems not to work for some reason.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    San Francisco Bay
    Posts
    1,939
    Rep Power
    1313
    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).
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    3
    Rep Power
    0
    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.

    Thanks
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Location
    usa,ill,chicago
    Posts
    6
    Rep Power
    0
    Same problem i am facing also but still failed to get solution...

IMN logo majestic logo threadwatch logo seochat tools logo