Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

all

I have tried to make a program from 'learn python the hard way'. it's exercise 25. in the extra credit it tells me to go help(ex25), but when I type that in, I get this on linux mint 15 terminal:

bash: syntax error near unexpected token `ex25'

please help. this is my coding:

def break_words(stuff):
    """this function will break-up words for us"""
    words = stuff.split(' ')
    return words

def sort_words(words):
    """sort the words"""
    return sorted(words)

def prints_first_word(words):
    """prints the first word after popping it"""
    word = words.pop (0)
    print word

def print_last_word(words):
    """prints the last word after popping it off"""
    word = words.pop(-1)
    print word

def sort_sentence(sentence):
    """takes in a whole sentence and sorts it"""
    words = break_words(sentence)
    return sort_words(words)

def print_first_and_last(sentence):
    """prints the first and last words of the sentence"""
    words = break_words(sentence)
    prints_first_word(words)
    print_last_word(words)

def print_first_and_last_sorted(sentence):
    """first sorts the words, then prints them"""
    words = sort_sentence(sentence)
    prints_first_word(words)
    print_last_word(words)
share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

I quick read through that example at http://learnpythonthehardway.org/book/ex25.html. Judging from your post, it sounds like you are typing help(ex25) at the bash prompt, while you should be typing that from within the python interpreter after doing the import ex25 first.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.