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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:09:11+00:00 2026-05-17T01:09:11+00:00

I have 2 Python scripts which are main_menu.py and inputip.py. The problem occurs when

  • 0

I have 2 Python scripts which are main_menu.py and inputip.py.

The problem occurs when I press "enter" to be redirected to main_menu.py when my function finishes in inputip.py. The script does not allow me to redirect to main_menu.py instead it shows this error on the Windows command prompt:

Traceback (most recent call last):
  File "C:\python\main_menu.py", line 32, in ?
    execfile('C:\python\Inputip.py')
  File "C:\python\Inputip.py", line 11, in ?
    input ("\nSelect enter to proceed back to Main Menu\n")
  File "<string>", line 0

^
SyntaxError: unexpected EOF while parsing

Here are my codes (main_menu.py):

def menu():
#print what options you have
print "Welcome to Simple Network Program"
print " "
print "Please enter a following option to proceed"
print " "
print "2) View Personal IP Address"
print " "
return input ("Select an Option here: ")
loop = 1
choice = 0
while loop == 1:
choice = menu()
if choice == 1:
    execfile('Inputip.py')
elif choice == 5:
    loop = 0
print "Thank you for using the Simple Network Program!"

The code (inputip.py):

#! /usr/bin/python

# To change this template, choose Tools | Templates
# and open the template in the editor.
import socket
import os
print ("\n\n"+socket.gethostbyname(socket.gethostname()))
input ("\nSelect enter to proceed back to Main Menu\n")

execfile('C:\python\main_menu.py')

The error seems to be pointing to the execfile. Some advice on the codes would be great. Thanks!

  • 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-05-17T01:09:12+00:00Added an answer on May 17, 2026 at 1:09 am

    Unless you are using python 3.x (but your question is not tagged as such), don’t use input. Use raw_input in stead. It will return strings, so convert them to int first, or do a string comparison. E.g.

    x = raw_input("Choice")
    if x == '1': 
        do_this()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server which executes Python scripts from a certain directory path. Incidently
I have a web service to which users upload python scripts that are run
I have a python framework which has to execute bash scripts as plugins. We
I have python script which downloads N number of images from website. I run
I have a python script which outputs lots of data, sample is as below.
i have a python script which keeps crashing on: subprocess.call([pdftotext, pdf_filename]) the error being:
I have a small python script which draws some turtle graphics. When my script
I have the following python script which takes some inputs and puts them in
I have written a python script which watches a directory for new subdirectories, and
In my Python script which uses Curses, I have a subwin to which some

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.