Follow us on Twitter!
The important thing is not to stop questioning. - Albert Einstein
Friday, April 18, 2014
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Members Online
Total Online: 32
Guests Online: 28
Members Online: 4

Registered Members: 82830
Newest Member: theimmortalcode
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming


Python program


Posts: 73
Location: Canada
Joined: 01.05.08
Posted on 10-08-08 22:41
Hey everyone, lately I've been learning to program with Python, and the last few hours I've been putting what I learned so far into practice by writing a simple (and useless) program, it has been going good except with my restart option only allows the user to restart once and then I get an error ( I will show you the error and the program below) and could not think of anyway around the program unless the user wants to turn off the program manually and start it again. Well here is the program:

# Practice
# Made by thehare

print " Hello Welcome to my practice 'game'"
print ""
print " This 'game' will ask you how you"
print " are doing and you will respond"         # Just the intro
print " by pressing 1,2,or 3 depending on"
print " what you want to do."
print ""

def menu(list, question):
    for entry in list:
        print 1 + list.index(entry),       
        print ") " + entry

    return input(question) -1

items = [" Good", " Bad", " Don't say anything"]    # Defining the menu

loop = 1
print ""
print "Hello How Are You "
print ""

print "Select one of the selections below"
# This is the main program:
while loop == 1:
    choice = menu(items,"How are you ?")
    if choice == 0:
          if loop == 1:                     
              print ""
              print "That is good "

              print ""
              loop = 2

    if choice == 1:
          if loop == 1:
              print ""
              print "That is to bad "

              print ""
              loop = 3

    if choice == 2:
          if loop == 1:
              print ""
              print "What, are you to good to talk to me? "

              print ""
              loop = 4
while loop == 2:
    print "Have a nice day"

    print ""
    loop = 0

while loop == 3:
    print "Hope your day improves"

    print ""
    loop = 0

while loop == 4:
    print "F$%# off"

    print ""
    loop = 0

#Below is the part of the program that either ends or restarts the program:
while loop == 0:
    print ""
    print "If you want to try the program again type yes";     
    print ""
    if a == 'yes':
        print "One second please..."
        print ""
        loop = 5                                             
    elif a == 'no':                                                         
        print " Goodbye"
        print ""
        loop = 6
        print "Command",a , "is unknown"
        print ""
        loop = 7

while loop == 6:
    print " Hope you enjoyed my program";
    print ":-)"
    print ""
    loop = 1

while loop == 7:
    print " Re-open program if needed"
    print ""
    loop = 1

# This is the restart script
while loop == 5:

    restart_file = open('', 'rd')       

    reader = py.reader(restart_file)

    print ""
    print restart_file

# Written By **thehare**

And here is the error I receive:

Traceback (most recent call last):
File "C:\Python25\", line 110, in <module>
File "C:\Python25\", line 110, in <module>
ImportError: No module named py

What could I do to solve this program?

Help would be appreciated, and any ideas on what to try to program next would be welcome to.

Thanks thehare

P.S And if you want to save it to your pc save it as, and change the smiley face to a bracket, and the you might have to manualy "tab" the program into position as I don't think that my tabs will go through.

If you need help, dont be afraid to ask, just be sure to give the challenge an honest try before you do.

Edited by thehare on 11-08-08 01:29

RE: Python program


Posts: 4192
Location: The Netherlands
Joined: 14.04.07
Warn Level: 90
Posted on 11-08-08 00:06
Try setting a PYTHONPATH.

P.S.: Disable your smileys.
"The chowner of property." - Zeph
Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert

Edited by spyware on 18-08-08 19:31

RE: Python program


Your avatar

Joined: 01.01.70
Posted on 18-08-08 19:30
You can't include the file extensions when importing. Type "import p" instead or just wrap it all in a while loop (with an optional break to exit the program)