Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 24th, 2008, 3:38 PM   #41
Chuckiferd
Programmer
 
Join Date: Nov 2007
Posts: 64
Rep Power: 1 Chuckiferd is on a distinguished road
Re: My pyguessinggame

I am sorry I mean without IDLE. I mean from the plain old original Python command line. Right now I can run the program just by clicking it as Windows is cool like that. But I wish to know why the python command line is incappable of running the program. I have heard that programmers often create seperate word doccuments and run them all sequencially in a single command line.
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't.
Chuckiferd is offline   Reply With Quote
Old Jan 24th, 2008, 4:11 PM   #42
Chuckiferd
Programmer
 
Join Date: Nov 2007
Posts: 64
Rep Power: 1 Chuckiferd is on a distinguished road
Re: My pyguessinggame

I wish to know as I am trying to make this a standalone py2exe, program.
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't.
Chuckiferd is offline   Reply With Quote
Old Jan 24th, 2008, 4:56 PM   #43
Chuckiferd
Programmer
 
Join Date: Nov 2007
Posts: 64
Rep Power: 1 Chuckiferd is on a distinguished road
Re: My pyguessinggame

Never mind ALL DONE. it is now a .exe file and everything. Thank you Sane and Titaniumdecoy and all you others who helped me out even after I managed to turn this overly simple project into a week long discussion covering 5 pages. Thank you all again
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't.
Chuckiferd is offline   Reply With Quote
Old Jan 24th, 2008, 6:45 PM   #44
Chuckiferd
Programmer
 
Join Date: Nov 2007
Posts: 64
Rep Power: 1 Chuckiferd is on a distinguished road
Re: My pyguessinggame

There is one last feature I want to add and that is the ability to go back and re-run the program. I don't know the command needed, is it continue or break, jeez maybe a goto funtion in python wouldn't be so bad
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't.
Chuckiferd is offline   Reply With Quote
Old Jan 24th, 2008, 6:52 PM   #45
Chuckiferd
Programmer
 
Join Date: Nov 2007
Posts: 64
Rep Power: 1 Chuckiferd is on a distinguished road
Re: My pyguessinggame

There is one last feature I want to add and that is the ability to go back and re-run the program. I don't know the command needed, is it continue or break, jeez maybe a goto funtion in python wouldn't be so bad

Srry about the double post, I can't find a way to get rid of it
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't.
Chuckiferd is offline   Reply With Quote
Old Jan 25th, 2008, 6:09 AM   #46
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,869
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: My pyguessinggame

Use your brain + some while loops. Experiment.

Also, your program crashes if you enter the number 100. Can you see why?
Sane is online now   Reply With Quote
Old Jan 25th, 2008, 9:31 AM   #47
Chuckiferd
Programmer
 
Join Date: Nov 2007
Posts: 64
Rep Power: 1 Chuckiferd is on a distinguished road
Re: My pyguessinggame

Yes I dubugged that and several other gramatical errors in the print statements. I am comming up with a way to confront the entering of strings, which cause the program to crash. I will try experimenting, however I believe all I need is a command to get back into the while loop from the if loop. of course I could copy the while and if loop over and over, but I know that would not be the prefered method.

I have tried
if guess == answer:
      print 'congratualtions, that took', guessnum, 'tries.'
      print
      a=raw_input('type in refresh to continue, or hit enter to quit')
      elif a='refresh':
         start()

but the game doesn't care for that too much and just closes.
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't.
Chuckiferd is offline   Reply With Quote
Old Jan 25th, 2008, 11:31 AM   #48
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,869
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: My pyguessinggame

Why are you using elif there?

A lot of your coding practices give me the idea that you haven't been reading any tutorials. You just look at some code and try to replicate it. While that works in some respects, sometimes you just end up having no clue what you're doing, or what you did.

Edit:

To solve the problem of entering strings, replace each "input" with "force_input" and add the following piece of code to the top of your program:

def force_input(prompt):
    while 1:
        try:
            return int(raw_input(prompt))
        except ValueError:
            print "Enter A Number. Not Text.\n"

So then, for example, one of your lines becomes:

guess=force_input('''I am thinking of a number that is in between 1 and 100''')

That will force the user to enter a number. I'll leave understanding that code as an exercise for you.

Last edited by Sane; Jan 25th, 2008 at 11:43 AM.
Sane is online now   Reply With Quote
Old Jan 25th, 2008, 3:46 PM   #49
Chuckiferd
Programmer
 
Join Date: Nov 2007
Posts: 64
Rep Power: 1 Chuckiferd is on a distinguished road
Re: My pyguessinggame

or I could use else which would take care of strings and anything else they try to throw at me, except the dreaded return, hmm its not working I thought that the option to restart was making all the errors and not the else: loop, but when I pulled the option to restart out, it still ran errors when I tried to enter non-integer characters.

By the way I have been reading the tutorials, The tutorial did not however tell me you had to start over with 'if' in the case it is already in a 'if' loop. I thought you just use elif. And that one peice of program is completly original, jeez if I was stealing programs you'd think I would try stealing ones that work lol
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't.
Chuckiferd is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:42 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC