Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:20:21+00:00 2026-06-02T20:20:21+00:00

Going through Learn Python the Hard Way, lesson 25. I try to execute the

  • 0

Going through Learn Python the Hard Way, lesson 25.

I try to execute the script, and the result is like so:

myComp:lphw becca$ python l25 

myComp:lphw becca$ 

Nothing prints or displays in terminal.

Here’s the code.

def breaks_words(stuff): 
    """This function will break up words for us."""
    words = stuff.split(' ')
    return words 

def sort_words(words):
    """Sorts the words."""
    return sorted(words)

def print_first_word(words):
    """Prints the first word after popping it off."""
    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 full sentence and returns the sorted words."""
    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)
    print_first_word(words)
    print_last_word(words)

def print_first_and_last_sorted(sentence):
    """Sorts the words then prints the first and last one."""
    words = sort_sentence(sentence)
    print_first_word(words)
    print_last_word(words)

Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:20:22+00:00Added an answer on June 2, 2026 at 8:20 pm

    All your code is function definitions, but you never call any of the functions, so the code doesn’t do anything.

    Defining a function with the def keyword just, well, defines a function. It doesn’t run it.

    For example, say you just have this function in your program:

    def f(x):
        print x
    

    You’re telling the program that whenever you call f, you want it to print the argument. But you’re not actually telling it that you want to call f, just what to do when you do call it.

    If you want to call the function on some argument, you need to do so, like this:

    # defining the function f - won't print anything, since it's just a function definition
    def f(x):
        print x
    # and now calling the function on the argument "Hello!" - this should print "Hello!"
    f("Hello!")
    

    So if you want your program to print something, you need to put in some calls to the functions you defined. What calls and with what arguments depends on what you want the code to do!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am going through the Learn Python the Hard Way, 2nd Edition book, and
About to start going through the 'Learn Python The Hard Way' book and I
I'm going through Learn Python the Hard Way 2nd Edition and I've just done
I'm trying to learn programming through Python and I like to know if it's
I'm trying to learn what iterators and generators are in python, going through a
I'm just starting programming and going through K&R to try and learn C. I've
I've been going through the learn.knockout.js tutorials and been experimenting. Can someone explain why
I'm going through the problems on projecteuler.net to learn how to program in Erlang,
I'm trying to learn F# by going through some of the Euler problems and
Trying to learn a bit about PDO and is going through this tutorial .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.