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 8799715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:23:53+00:00 2026-06-14T00:23:53+00:00

I made a small program in Python (.py) and converted it into a Windows

  • 0

I made a small program in Python (.py) and converted it into a Windows executable file (.exe) using Py2exe. It asks for a string and then outputs a string — very simple! — and works flawlessly in Python.

However, when the exe file finishes execution in the command window, the command window closes automatically before I can get a glimpse of its output (I assume it does print the output because, like I said, it works flawlessly in Python).

How can I prevent this from happening? I assume I need to change my code, but what exactly do I need to add to it?

Here is my code, in case it helps you to see it (it’s a word-wrapper):

import string

def insertNewlines(text, lineLength):
    if text == '':
        return ''
    elif len(text) <= lineLength:
        return text
    elif text[lineLength] == ' ':
        return text[:lineLength] + '\n' + insertNewlines(text[lineLength+1:], lineLength)
    elif text[lineLength-1] == ' ':
        return text[:lineLength] + '\n' + insertNewlines(text[lineLength:], lineLength)
    else:
        if string.find(text, ' ', lineLength) == -1:
            return text
        else:
            return text[:string.find(text,' ',lineLength)+1] + '\n' + insertNewlines(text[string.find(text,' ',lineLength)+1:], lineLength)
    print

if __name__ == '__main__':
    text = str(raw_input("Enter text to word-wrap: "))
    lineLength = int(raw_input("Enter number of characters per line: "))
    print 
    print insertNewlines(text, lineLength)

Thank you.

  • 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-14T00:23:54+00:00Added an answer on June 14, 2026 at 12:23 am

    The simplest way is probably to use raw_input() just before your program finishes. It will wait until you hit enter before closing.

    if __name__ == '__main__':
        text = str(raw_input("Enter text to word-wrap: "))
        lineLength = int(raw_input("Enter number of characters per line: "))
        print 
        print insertNewlines(text, lineLength)
        raw_input()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have made a small opengl program using the d programming language. what i
I made this small Java program using eclipse IDE. I have set the workspace
I have made a small program in c# called Registry.exe. Now i my c++
I made small program to divide large pictures and take part of them. When
I've made a small program which has 2 buttons and each does certain thing.
I've made a small program in C++ and Qt. The program displays a list
Problem: Have made a small mail program which works perfectly on my developer pc
For a program of mine I made a small function to clear the various
I made this small program to test parallelization. When I hit button1 several times
I am running a little program in python that launches a small window that

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.