Help with guessing game :D

R

rurpy

So from the most recent post do you infer that your explanations
were successful in creating some understanding?

I have been suitably chastened and will have more respect for a variety
of approaches in the future.
 
R

rurpy

Thank you very much for your reply, however it gives me an error,
something about the "end", do you know whats wrong with it?
(Still not sure if im posting this right so sorry)

"...an error, something about the 'end'" is not much to go on. :)

Most of the time, when there is an error in a python program,
Python will print "traceback" error message. When asking for
help please copy and paste those lines in your post. Without
that it is just a guessing game for anyone to try and figure
out what is wrong.

Did perhaps your traceback message look like this?

File "xx3.py", line 28
print ("digits matched: ", end='')
^

If so, you are running your program with python2, not python3.
So you need to either figure out how to run python3 (does entering
the command "python3" do anything?) or change the program to work
with python2.

If the error message was different than above, you need to post
it here if people are to have any chance of helping you figure
out what is wrong.
 
R

rusi

I have been suitably chastened and will have more respect for a variety
of approaches in the future.

Heh! Dont be hard on yourself!
When youve been a teacher long enough you will know
- communication is the exception*
- misunderstanding is quite ok
- non-understanding is the norm

* Yeah Fr. Thomas Keating talks about the fact that he prefers communion to communication. Hopefully when I go to heaven I'll find out how the admin there is so efficient
 
R

Robert Gonda

"...an error, something about the 'end'" is not much to go on. :)



Most of the time, when there is an error in a python program,

Python will print "traceback" error message. When asking for

help please copy and paste those lines in your post. Without

that it is just a guessing game for anyone to try and figure

out what is wrong.



Did perhaps your traceback message look like this?



File "xx3.py", line 28

print ("digits matched: ", end='')

^



If so, you are running your program with python2, not python3.

So you need to either figure out how to run python3 (does entering

the command "python3" do anything?) or change the program to work

with python2.



If the error message was different than above, you need to post

it here if people are to have any chance of helping you figure

out what is wrong.
 
R

Robert Gonda

never mind you was right, for some reason I had version 2.7 :/ , and btw I was wondering, is it also possible to make it more complex? such as if the computer will again show “Y” if a digit is correct but if a digit is incorrect it will say "H" as in too high or “L” if it's too low? (whilestill keeping "Y"). Do tell me if it sounds confusing :/
 
D

Dave Angel

On 29/10/2013 14:05, Robert Gonda wrote:


& >> Back to question, name is also not working, I currently have
python 3.3.2 and the only to get that work is the write raw_input, I
have no idea why, did i do soemthing wrong?


Why did you add those two >> symbols in front of your new text? Each
such symbol is supposed to indicate that another level of quoting is
occuring. So when I saw your message, I first concluded that you sent a
blank reply.

(I also added another character in front of it, so you'd see it.
Apparently googlegroups messes up your view of things in order to cover
up its bugs in posting.

As for your question. Yes, you did something wrong. You thoroughly
underspecified the phrase "not working."

When you run a program and it gets an exception, read the whole
traceback. And when you want help here, copy the WHOLE TRACEBACk.

If raw_input() is working without an exception, then you are NOT running
Python3.x. Figure that out first, perhaps by sticking these two lines
at the beginning of your code:

import sys
print(sys.version)
 
R

Robert Gonda

On 29/10/2013 14:05, Robert Gonda wrote:





& >> Back to question, name is also not working, I currently have

python 3.3.2 and the only to get that work is the write raw_input, I

have no idea why, did i do soemthing wrong?





Why did you add those two >> symbols in front of your new text? Each

such symbol is supposed to indicate that another level of quoting is

occuring. So when I saw your message, I first concluded that you sent a

blank reply.



(I also added another character in front of it, so you'd see it.

Apparently googlegroups messes up your view of things in order to cover

up its bugs in posting.



As for your question. Yes, you did something wrong. You thoroughly

underspecified the phrase "not working."



When you run a program and it gets an exception, read the whole

traceback. And when you want help here, copy the WHOLE TRACEBACk.



If raw_input() is working without an exception, then you are NOT running

Python3.x. Figure that out first, perhaps by sticking these two lines

at the beginning of your code:



import sys

print(sys.version)
 
R

rurpy

never mind you was right, for some reason I had version 2.7 :/ ,
and btw I was wondering, is it also possible to make it more
complex? such as if the computer will again show “Y” if a digit
is correct but if a digit is incorrect it will say "H" as in
too high or “L” if it's too low? (while still keeping "Y").
Do tell me if it sounds confusing :/

Sure it's possible. What do you think would happen if you
replaced the code that compares the digits and prints Y or
N with with something like this?

if guess_str > number_str: print ("H", end='')
if guess_str < number_str: print ("L", end='')
if guess_str == number_str: print ("Y", end='')

(you are comparing 1-character long strings containing a
digit between "0" and "9" but they will compare the same
way numbers do.)
 
R

Robert Gonda

never mind you was right, for some reason I had version 2.7 :/ ,
and btw I was wondering, is it also possible to make it more
complex? such as if the computer will again show “Y” if a digit
is correct but if a digit is incorrect it will say "H" as in
too high or “L” if it's too low? (while still keeping "Y").
Do tell me if it sounds confusing :/



Sure it's possible. What do you think would happen if you

replaced the code that compares the digits and prints Y or

N with with something like this?



if guess_str > number_str: print ("H", end='')

if guess_str < number_str: print ("L", end='')

if guess_str == number_str: print ("Y", end='')



(you are comparing 1-character long strings containing a

digit between "0" and "9" but they will compare the same

way numbers do.)
 
R

Robert Gonda

never mind you was right, for some reason I had version 2.7 :/ ,
and btw I was wondering, is it also possible to make it more
complex? such as if the computer will again show “Y” if a digit
is correct but if a digit is incorrect it will say "H" as in
too high or “L” if it's too low? (while still keeping "Y").
Do tell me if it sounds confusing :/



Sure it's possible. What do you think would happen if you

replaced the code that compares the digits and prints Y or

N with with something like this?



if guess_str > number_str: print ("H", end='')

if guess_str < number_str: print ("L", end='')

if guess_str == number_str: print ("Y", end='')



(you are comparing 1-character long strings containing a

digit between "0" and "9" but they will compare the same

way numbers do.)
 
R

rurpy

Is it possible to further more specify it? H only shows if the
guess is at most 3 higher then the answer?. But L is only given
if the guess is at most 3 lower the answer? I'm starting to
like this ;D

To do that, you'll need to convert the string digits back to
numbers that you can do arithmetic on. The int() function
can do that. Then you can do something like

if guess_num > number_num + 3: ... print what you want here.

You'll find you get more and better answers to your questions
if you attempt to do something yourself and when you find it is
not doing what you want, post here saying what you tried, what
it did, and how what it did is different from what you want.

You'll also get better responses if you edit out the empty
and excess ">" lines in the quoted text of your replies,
which you are still not doing.
 
D

Dave Angel

On 29/10/2013 15:15, Robert Gonda wrote:

(once again deleting all the double-spaced Googlegroups nonsense)
&& >>Hi dave, yes you was right. I had python 2.7 but I upgraded to
python 3 now, thanks for help :) by the way, is this showing normally?

No, you're still adding a ">" character before the stuff you typed.
That's supposed to show what you are quoting. One bracket is the person
you're replying to, two marks the stuff he was quoting, and so on.

Any decent mail program does it for you automatically, or with minimum
configuration.

Only googlegroups messes it up so consistently.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Guess the Number Repeat 1
Help in hangman game 1
vhdl guessing game 2
Python Unit Tests 10
Python battle game help 2
guessthenumber print games left 14
Tic Tac Toe Game 2
Guessing the encoding from a BOM 7

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top