![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#31 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,722
Rep Power: 5
![]() |
Re: My pyguessinggame
That's so strange. That error message means there's some non-ascii characters in your source code. I can't see any...
Try removing that first line all together. |
|
|
|
|
|
#32 |
|
Programmer
Join Date: Nov 2007
Posts: 61
Rep Power: 1
![]() |
Re: My pyguessinggame
same thing everytime
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#33 |
|
Programmer
Join Date: Nov 2007
Posts: 61
Rep Power: 1
![]() |
Re: My pyguessinggame
with just a raw_imput command it still has the same message, could it be the path, mine is
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C;\Python25
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#34 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,722
Rep Power: 5
![]() |
Re: My pyguessinggame
lol, you're still saying "raw_imput" instead of "raw_input".
It doesn't sound like a problem with your Path if Python is successfully running. It sounds like a problem with how the files are being encoded, because it thinks you're trying to use illegal characters. Have you tried running the program in IDLE? Open up IDLE (Python GUI). Open your script. Hit F5. |
|
|
|
|
|
#35 |
|
Programmer
Join Date: Nov 2007
Posts: 61
Rep Power: 1
![]() |
Re: My pyguessinggame
but I am not using illegal characters, I am using a typical American keyboard, you will find no chinese characters on this keyboard, wait could it be the font? (I am truly sorry about the raw_imp- whoops I mean raw_input mistake for some reason I just am having trouble spelling it right)
PS. I got the game to run, well sorta, it went like this 1.) I copy guessgamev2.0.py into the python command line, via. copy + pasting the text 2.) I type in start() 3.) Here is the result (stuff in blue is input) I am thinking of a number that is in between 1 and 100 3 that guess is way too high, the answer has to be 100 or lower 1000 that guess is way too high, the answer has to be 100 or lower -1000000 that guess is way too high, the answer has to be 100 or lower 0 that guess is way too high, the answer has to be 100 or lower, ect. ect. ect. ect. As you can see, nothing happened that was supposed to happen.
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#36 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,722
Rep Power: 5
![]() |
Re: My pyguessinggame
About the character encoding, you were writing the file in Microsoft Word or WordPad or some other word-processing application now weren't you... Source code should always be in plaintext. So use the Python GUI. Word processing applications always bloat your file with other information pertaining to the font, size, formatting, etc... Plaintext means there are ASCII characters, and nothing more, which is why you should be using IDLE (or Notepad) to write your Python scripts.
Now... "raw_input" is for taking in strings. "input" is for taking in numbers. If you try to compare a string with the value obtained from randint (a number), it doesn't work as expected. >>> print "50" > 40 True >>> print "50" > 60 True You want to compare numbers with numbers. >>> print 50 > 40 True >>> print 50 > 60 False You can obtain a number from the user with "input" rather than "raw_input". Or you can typecast the string to an integer with guess = int(raw_input("Enter A Number: ")) which is "safer".I forgot I had made that change to your code on my version when I was fixing all of the syntax errors. |
|
|
|
|
|
#37 |
|
Programmer
Join Date: Nov 2007
Posts: 61
Rep Power: 1
![]() |
Re: My pyguessinggame
yeah I got it to work with just double clicking, sorta
One last time #guessgame********** (1/20/08)
from random import randint
def start():
answer=randint(1,101) #the answer
guessnum=0 #number of user guesses
guess=input('''I am thinking of a number that is in between 1 and 100''')#the current guess of the user
while guess != answer:
guessnum=guessnum+1
if guess > 100:
print '''that guess is way too high, the answer has to be 100 or lower'''
guess=input ('''guess again please, within the limit this time''')
elif guess == 0:
print 'actually zero is not within the 1-100 range'
guess=input('guess again please')
elif guess < 0:
print 'are you testing me?'
guess=input('guess again, in the positives please')
elif guess > 0 and guess < 100 and guess < answer:
print 'that guess is below the answer'
guess=input('try guessing again')
elif guess >0 and guess < 100 and guess > answer:
print 'guess lower, your answer is to high'
guess=input('try once more')
if guess == answer:
print 'congratualtions, that took', guessnum, 'tries'
if __name__ == '__main__':
start()
print
raw_input('press return')
else:
print 'Module guessgame imported'
print 'to run, type:guessgame.start()'
print 'to refresh, type:reload (guessgame)'
#end game
raw_input('press enter to quit')Came out with ![]() Only the ending ended up getting printed EDIT:Whooooooop!!!! I did it, except I did it only by coping the data to the command line. I need to figure out how to remotely open the file.
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. Last edited by Chuckiferd; Jan 24th, 2008 at 1:35 PM. |
|
|
|
|
|
#38 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,722
Rep Power: 5
![]() |
Re: My pyguessinggame
You still have code indented incorrectly...
if __name__ == '__main__':
start()
print
raw_input('press return')
else:
print 'Module guessgame imported'
print 'to run, type:guessgame.start()'
print 'to refresh, type:reload (guessgame)'Should be indented like so: #guessgame********** (1/20/08)
from random import randint
def start():
answer=randint(1,101) #the answer
guessnum=0 #number of user guesses
guess=input('''I am thinking of a number that is in between 1 and 100''')#the current guess of the user
while guess != answer:
guessnum=guessnum+1
if guess > 100:
print '''that guess is way too high, the answer has to be 100 or lower'''
guess=input ('''guess again please, within the limit this time''')
elif guess == 0:
print 'actually zero is not within the 1-100 range'
guess=input('guess again please')
elif guess < 0:
print 'are you testing me?'
guess=input('guess again, in the positives please')
elif guess > 0 and guess < 100 and guess < answer:
print 'that guess is below the answer'
guess=input('try guessing again')
elif guess >0 and guess < 100 and guess > answer:
print 'guess lower, your answer is to high'
guess=input('try once more')
if guess == answer:
print 'congratualtions, that took', guessnum, 'tries'
if __name__ == '__main__':
start()
print
raw_input('press return')
else:
print 'Module guessgame imported'
print 'to run, type:guessgame.start()'
print 'to refresh, type:reload (guessgame)'
#end game
raw_input('press enter to quit')And what in the world are you talking about with "remotely opening the file"? Again... just use IDLE and run it from there. As simple as that... |
|
|
|
|
|
#39 |
|
Programmer
Join Date: Nov 2007
Posts: 61
Rep Power: 1
![]() |
Re: My pyguessinggame
By 'remotely activating the file' I meant opening it and running it without having to copy and paste from a notepad document.
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#40 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,722
Rep Power: 5
![]() |
Re: My pyguessinggame
Yes, for the fourth time. IDLE!
Start -> Programs -> Python -> IDLE (Python GUI) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|