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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:15:08+00:00 2026-06-09T14:15:08+00:00

So, as the title says, I want a proper code to close my python

  • 0

So, as the title says, I want a proper code to close my python script.
So far, I’ve used input('Press Any Key To Exit'), but what that does, is generate an error.
I want a code that closes your script without using an error.

Does anyone have an idea? Google gives me the input option, but I don’t want that
It closes using this error:

Traceback (most recent call last):
  File "C:/Python27/test", line 1, in <module>
    input('Press Any Key To Exit')
  File "<string>", line 0
    
   ^
SyntaxError: unexpected EOF while parsing
  • 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-09T14:15:09+00:00Added an answer on June 9, 2026 at 2:15 pm

    This syntax error is caused by using input on Python 2, which will try to eval whatever is typed in at the terminal prompt. If you’ve pressed enter then Python will essentially try to eval an empty string, eval(""), which causes a SyntaxError instead of the usual NameError.

    If you’re happy for "any" key to be the enter key, then you can simply swap it out for raw_input instead:

    raw_input("Press Enter to continue")
    

    Note that on Python 3 raw_input was renamed to input.

    For users finding this question in search, who really want to be able to press any key to exit a prompt and not be restricted to using enter, you may consider to use a 3rd-party library for a cross-platform solution. I recommend the helper library readchar which can be installed with pip install readchar. It works on Linux, macOS, and Windows and on either Python 2 or Python 3.

    import readchar
    print("Press Any Key To Exit")
    k = readchar.readchar()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The title says it mostly. If I have an object in Python and want
Just as the title says. I want to write a script that behaves differently
As the title says, I want to parse some Java source code in Java.
Like the title says I want to use a color code instead of doing
The title says all I want to know. Is there any function or I
As the title says, I want to truncate user-input text string based on the
As title says. I want to perform and order by on a list -
I just want what my title says.I have already read all the previous similar
Basically what the title says, I want to get the URL and HTTP Verb
Though the title says everything, I want to let you know the particular scenario

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.