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

    Join Date
    Jun 2013
    Posts
    22
    Rep Power
    0

    Simple program issue


    Hi im having trouble with this, I cant see where the syntax error is

    def first(word):
    return word[0]

    def last(word):
    return word[-1]

    def middle(word):
    return(word[1:-1]

    middle(python)

    I get a syntax error for some reason
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    Originally Posted by jpg123
    Hi im having trouble with this, I cant see where the syntax error is

    Code:
    def first(word):
        return word[0]
    
    def last(word):
        return word[-1]
    
    def middle(word):
        return(word[1:-1]
           
    middle(python)
    I get a syntax error for some reason
    You have an unnecessary parenthesis on the return line of your middle function. Also I believe you intend to pass middle the string "python" unless you have a variable python defined somewhere.

    -Mek
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    22
    Rep Power
    0
    yeah I just saw it, cheers for the reply

IMN logo majestic logo threadwatch logo seochat tools logo