Re: Hey, I'm new to python so don't judge.
When i check the code it comes up with invalid syntax and my writing line gets re directed here def is_same(target, number: if target == number: result="win" elif target > number: result="low" else: result="high" return result -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:03:18 PM UTC+13, Erik wrote: > On 03/01/17 23:56, Chris Angelico wrote: > > On Wed, Jan 4, 2017 at 10:49 AM, wrote: > >> #think of a number > >> computer_number = number.randint(1,100) > > > > What's wrong is that you aren't showing us the exception you get on > > this line. *Copy and paste* that exception - the whole thing. It's > > very helpful. > > I doubt it's getting that far (I can see at least one syntax error in > the code pasted). > > cr2001: I echo Chris's sentiment though - what is the error you are > seeing (in it's entirety)? > > E. My apologizes but i'm quite new and would need instructions to what information you need me to get. -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:17:11 PM UTC+13, Chris Angelico wrote: > On Wed, Jan 4, 2017 at 11:03 AM, Erik wrote: > > I doubt it's getting that far (I can see at least one syntax error in the > > code pasted). > > True true. In any case, the point is to copy and paste the error > message. Callum, please, copy and paste it. > > ChrisA I'm sorry if I'm doing something wrong but all that is happening is when i try to run it a popup says Invalid syntax -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:26:26 PM UTC+13, Erik wrote:
> Hi Callum,
>
> On 04/01/17 00:02, Callum Robinson wrote:
> > When i check the code it comes up with invalid syntax and my writing
> line gets re directed here
> >
> > def is_same(target, number:
> > if target == number:
> > result="win"
> > elif target > number:
> > result="low"
> > else:
> > result="high"
> > return result
>
> OK, good. That implies it's something wrong with the function definition
> ('def'). Look at that very carefully :) (*)
>
> E.
>
> (*) My emoticon may give you a hint ...
I feel like im missing something so blatantly obvious.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:26:26 PM UTC+13, Erik wrote:
> Hi Callum,
>
> On 04/01/17 00:02, Callum Robinson wrote:
> > When i check the code it comes up with invalid syntax and my writing
> line gets re directed here
> >
> > def is_same(target, number:
> > if target == number:
> > result="win"
> > elif target > number:
> > result="low"
> > else:
> > result="high"
> > return result
>
> OK, good. That implies it's something wrong with the function definition
> ('def'). Look at that very carefully :) (*)
>
> E.
>
> (*) My emoticon may give you a hint ...
I forgot a bloody bracket xD
and now theirs a new error ill try to figure this out on my own.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:45:22 PM UTC+13, Erik wrote:
> Hi Callum,
>
> On 04/01/17 00:30, Callum Robinson wrote:
> > I feel like im missing something so blatantly obvious.
>
> That's because you are ;). I don't want to come across as patronising,
> but I want you to see it for yourself, so, here's a function definition
> similar to yours that doesn't have the same syntax error that yours does:
>
> def foo(spam, ham):
> if spam == ham:
> return "same"
> return "different"
>
> See the difference?
>
> E.
I've figured out that out but I have a new issue. I like what you are doing
making me figure this out as it helps me remember. I'll post the new code and
the issue. If you could give me a hint that would be great.
--
Issue
--
Traceback (most recent call last):
File "D:/Python/random.py", line 6, in
computer_number = number.randint(1, 100)
NameError: name 'number' is not defined
-
Here is the most recent code
-
# mynumber.py
# this game uses a home made function
import random
#think of a number
computer_number = number.randint(1, 100)
#create the function is_same()
def is_same(target, number):
if target == number:
result="Win"
elif target > number:
result="Low"
else:
result="High"
return result
# start the game
print("hello. \nI have thought of a number between 1 and 100.")
#collect the user's guess as an interger
guess = int(input("Can you guess it? "))
#Use our function
higher_or_lower = is_same(computer_number, guess)
#run the game untill the user is correct
while higher_or_lower != "win":
if higher_or_lower == "low":
guess = int(input("Sorry, you are too low. Try again."))
else:
guess = int(input("Sorry your are too high. Try again."))
higher_or_lower = is_same(computer_number, guess)
#end of game
input("Correct!\nWell Done\n\n\nPress RETURN to exit.")
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 2:16:08 PM UTC+13, Steve D'Aprano wrote: > On Wed, 4 Jan 2017 12:04 pm, Callum Robinson wrote: > > > Traceback (most recent call last): > > File "D:/Python/random.py", line 6, in > > computer_number = number.randint(1, 100) > > NameError: name 'number' is not defined > > > That's exactly what we need to see! The full traceback, thank you! > > You're asking Python to get the variable "number", and call the randint > method. But: > > - you don't have a variable called "number"; > > NameError: name 'number' is not defined > > > - and even if you did, that's not how you get a random number. What you want > is: > > computer_number = random.randint(1, 100) > > > > > > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. Hey man thanks, the sad thing is i have no idea why i put that in. I must be having a terrible day. -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 12:49:28 PM UTC+13, Callum Robinson wrote:
> Im doing a new task from my teacher but i can't seem to find what is wrong
> with this code. Can anyone help?
>
> #mynumber.py
> # this game uses a home made function
> import random
>
> #think of a number
> computer_number = number.randint(1,100)
>
> #create the function is_same()
> def is_same(target, number:
> if target == number:
> result="win"
> elif target > number:
> result="low"
> else:
> result="high"
> return result
>
> # start the game
> print("hello. \nI have thought of a number between 1 and 100.")
>
> #collect the user's guess as an interger
> guess = int(input("Can you guess it? "))
> #Use our function
> higher_or_lower = is_same(computer_number, guess)
> #run the game untill the user is correct
> while higher_or_lower != "win"
> if higher_or_lower == "to low"
> guess = int(input("Sorry, you are too low. Try again."))
> else:
> guess = int(input("Sorry your are too high. Try again."))
>
> higher_or_lower = is_same(computer_number, guess)
>
> #end of game
> input("Correct!\nWell Done\n\n\nPress RETURN to exit.")
Hey again, i'm sorry for bothering you with so many questions i just did not
want to keep asking my teacher who is on holiday these.
I have another issue where the code runs but i can guess every number from
1-100 but it always says Sorry your are too high. Try again. I don't understand
what i have done to cause this.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 3:05:48 PM UTC+13, MRAB wrote:
> On 2017-01-04 01:37, Callum Robinson wrote:
> > On Wednesday, January 4, 2017 at 12:49:28 PM UTC+13, Callum Robinson wrote:
> >> Im doing a new task from my teacher but i can't seem to find what is wrong
> >> with this code. Can anyone help?
> >>
> >> #mynumber.py
> >> # this game uses a home made function
> >> import random
> >>
> >> #think of a number
> >> computer_number = number.randint(1,100)
> >>
> >> #create the function is_same()
> >> def is_same(target, number:
> >> if target == number:
> >> result="win"
> >> elif target > number:
> >> result="low"
> >> else:
> >> result="high"
> >> return result
> >>
> >> # start the game
> >> print("hello. \nI have thought of a number between 1 and 100.")
> >>
> >> #collect the user's guess as an interger
> >> guess = int(input("Can you guess it? "))
> >> #Use our function
> >> higher_or_lower = is_same(computer_number, guess)
> >> #run the game untill the user is correct
> >> while higher_or_lower != "win"
> >> if higher_or_lower == "to low"
> >> guess = int(input("Sorry, you are too low. Try again."))
> >> else:
> >> guess = int(input("Sorry your are too high. Try again."))
> >>
> >> higher_or_lower = is_same(computer_number, guess)
> >>
> >> #end of game
> >> input("Correct!\nWell Done\n\n\nPress RETURN to exit.")
> >
> > Hey again, i'm sorry for bothering you with so many questions i just did
> > not want to keep asking my teacher who is on holiday these.
> >
> > I have another issue where the code runs but i can guess every number from
> > 1-100 but it always says Sorry your are too high. Try again. I don't
> > understand what i have done to cause this.
> >
> What values can 'is_same' return?
>
> Which of those values are you checking for in the loop?
I'm sorry but i do not completely understand what you are stating
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 3:35:53 PM UTC+13, Erik wrote: > On 04/01/17 02:24, Callum Robinson wrote: > > On Wednesday, January 4, 2017 at 3:05:48 PM UTC+13, MRAB wrote: > >> What values can 'is_same' return? > >> > >> Which of those values are you checking for in the loop? > > > > I'm sorry but i do not completely understand what you are stating > > You need to think about the specific things (their type, their exact > values) that your functions might return. Printing some trace output is > a classic way of debugging your program. If, after this line: > > >>>> higher_or_lower = is_same(computer_number, guess) > > ... you added: > > print (higher_or_lower) > > ... what values do you then see being output? How will those values be > processed by the conditions you see that work on the "higher_or_lower" > variable? > > E. I did it and this is what it states when i run it hello. I have thought of a number between 1 and 100. Can you guess it? 5 Low Sorry , you are too high. Try again. Does this mean the number i entered is to low but the code is still stating it is to high? -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:17:11 PM UTC+13, Chris Angelico wrote: > On Wed, Jan 4, 2017 at 11:03 AM, Erik wrote: > > I doubt it's getting that far (I can see at least one syntax error in the > > code pasted). > > True true. In any case, the point is to copy and paste the error > message. Callum, please, copy and paste it. > > ChrisA I'm sorry if I'm doing something wrong but all that is happening is when i try to run it a popup says Invalid syntax -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
When i check the code it comes up with invalid syntax and my writing line gets re directed here def is_same(target, number: if target == number: result="win" elif target > number: result="low" else: result="high" return result -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:26:26 PM UTC+13, Erik wrote:
> Hi Callum,
>
> On 04/01/17 00:02, Callum Robinson wrote:
> > When i check the code it comes up with invalid syntax and my writing
> line gets re directed here
> >
> > def is_same(target, number:
> > if target == number:
> > result="win"
> > elif target > number:
> > result="low"
> > else:
> > result="high"
> > return result
>
> OK, good. That implies it's something wrong with the function definition
> ('def'). Look at that very carefully :) (*)
>
> E.
>
> (*) My emoticon may give you a hint ...
I forgot a bloody bracket xD
and now theirs a new error ill try to figure this out on my own.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:03:18 PM UTC+13, Erik wrote: > On 03/01/17 23:56, Chris Angelico wrote: > > On Wed, Jan 4, 2017 at 10:49 AM, wrote: > >> #think of a number > >> computer_number = number.randint(1,100) > > > > What's wrong is that you aren't showing us the exception you get on > > this line. *Copy and paste* that exception - the whole thing. It's > > very helpful. > > I doubt it's getting that far (I can see at least one syntax error in > the code pasted). > > cr2001: I echo Chris's sentiment though - what is the error you are > seeing (in it's entirety)? > > E. My apologizes but i'm quite new and would need instructions to what information you need me to get. -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 2:16:08 PM UTC+13, Steve D'Aprano wrote: > On Wed, 4 Jan 2017 12:04 pm, Callum Robinson wrote: > > > Traceback (most recent call last): > > File "D:/Python/random.py", line 6, in > > computer_number = number.randint(1, 100) > > NameError: name 'number' is not defined > > > That's exactly what we need to see! The full traceback, thank you! > > You're asking Python to get the variable "number", and call the randint > method. But: > > - you don't have a variable called "number"; > > NameError: name 'number' is not defined > > > - and even if you did, that's not how you get a random number. What you want > is: > > computer_number = random.randint(1, 100) > > > > > > > -- > Steve > â £Cheer up,â Ø they said, â £things could be worse.â Ø So I cheered up, and sure > enough, things got worse. Hey man thanks, the sad thing is i have no idea why i put that in. I must be having a terrible day. -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:26:26 PM UTC+13, Erik wrote:
> Hi Callum,
>
> On 04/01/17 00:02, Callum Robinson wrote:
> > When i check the code it comes up with invalid syntax and my writing
> line gets re directed here
> >
> > def is_same(target, number:
> > if target == number:
> > result="win"
> > elif target > number:
> > result="low"
> > else:
> > result="high"
> > return result
>
> OK, good. That implies it's something wrong with the function definition
> ('def'). Look at that very carefully :) (*)
>
> E.
>
> (*) My emoticon may give you a hint ...
I feel like im missing something so blatantly obvious.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 12:49:28 PM UTC+13, Callum Robinson wrote:
> Im doing a new task from my teacher but i can't seem to find what is wrong
with this code. Can anyone help?
>
> #mynumber.py
> # this game uses a home made function
> import random
>
> #think of a number
> computer_number = number.randint(1,100)
>
> #create the function is_same()
> def is_same(target, number:
> if target == number:
> result="win"
> elif target > number:
> result="low"
> else:
> result="high"
> return result
>
> # start the game
> print("hello. \nI have thought of a number between 1 and 100.")
>
> #collect the user's guess as an interger
> guess = int(input("Can you guess it? "))
> #Use our function
> higher_or_lower = is_same(computer_number, guess)
> #run the game untill the user is correct
> while higher_or_lower != "win"
> if higher_or_lower == "to low"
> guess = int(input("Sorry, you are too low. Try again."))
> else:
> guess = int(input("Sorry your are too high. Try again."))
>
> higher_or_lower = is_same(computer_number, guess)
>
> #end of game
> input("Correct!\nWell Done\n\n\nPress RETURN to exit.")
Hey again, i'm sorry for bothering you with so many questions i just did not
want to keep asking my teacher who is on holiday these.
I have another issue where the code runs but i can guess every number from
1-100 but it always says Sorry your are too high. Try again. I don't understand
what i have done to cause this.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 1:45:22 PM UTC+13, Erik wrote:
> Hi Callum,
>
> On 04/01/17 00:30, Callum Robinson wrote:
> > I feel like im missing something so blatantly obvious.
>
> That's because you are ;). I don't want to come across as patronising,
> but I want you to see it for yourself, so, here's a function definition
> similar to yours that doesn't have the same syntax error that yours does:
>
> def foo(spam, ham):
> if spam == ham:
> return "same"
> return "different"
>
> See the difference?
>
> E.
I've figured out that out but I have a new issue. I like what you are doing
making me figure this out as it helps me remember. I'll post the new code and
the issue. If you could give me a hint that would be great.
--
Issue
--
Traceback (most recent call last):
File "D:/Python/random.py", line 6, in
computer_number = number.randint(1, 100)
NameError: name 'number' is not defined
-
Here is the most recent code
-
# mynumber.py
# this game uses a home made function
import random
#think of a number
computer_number = number.randint(1, 100)
#create the function is_same()
def is_same(target, number):
if target == number:
result="Win"
elif target > number:
result="Low"
else:
result="High"
return result
# start the game
print("hello. \nI have thought of a number between 1 and 100.")
#collect the user's guess as an interger
guess = int(input("Can you guess it? "))
#Use our function
higher_or_lower = is_same(computer_number, guess)
#run the game untill the user is correct
while higher_or_lower != "win":
if higher_or_lower == "low":
guess = int(input("Sorry, you are too low. Try again."))
else:
guess = int(input("Sorry your are too high. Try again."))
higher_or_lower = is_same(computer_number, guess)
#end of game
input("Correct!\nWell Done\n\n\nPress RETURN to exit.")
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 3:05:48 PM UTC+13, MRAB wrote:
> On 2017-01-04 01:37, Callum Robinson wrote:
> > On Wednesday, January 4, 2017 at 12:49:28 PM UTC+13, Callum Robinson wrote:
> >> Im doing a new task from my teacher but i can't seem to find what is wrong
with this code. Can anyone help?
> >>
> >> #mynumber.py
> >> # this game uses a home made function
> >> import random
> >>
> >> #think of a number
> >> computer_number = number.randint(1,100)
> >>
> >> #create the function is_same()
> >> def is_same(target, number:
> >> if target == number:
> >> result="win"
> >> elif target > number:
> >> result="low"
> >> else:
> >> result="high"
> >> return result
> >>
> >> # start the game
> >> print("hello. \nI have thought of a number between 1 and 100.")
> >>
> >> #collect the user's guess as an interger
> >> guess = int(input("Can you guess it? "))
> >> #Use our function
> >> higher_or_lower = is_same(computer_number, guess)
> >> #run the game untill the user is correct
> >> while higher_or_lower != "win"
> >> if higher_or_lower == "to low"
> >> guess = int(input("Sorry, you are too low. Try again."))
> >> else:
> >> guess = int(input("Sorry your are too high. Try again."))
> >>
> >> higher_or_lower = is_same(computer_number, guess)
> >>
> >> #end of game
> >> input("Correct!\nWell Done\n\n\nPress RETURN to exit.")
> >
> > Hey again, i'm sorry for bothering you with so many questions i just did
not want to keep asking my teacher who is on holiday these.
> >
> > I have another issue where the code runs but i can guess every number from
1-100 but it always says Sorry your are too high. Try again. I don't understand
what i have done to cause this.
> >
> What values can 'is_same' return?
>
> Which of those values are you checking for in the loop?
I'm sorry but i do not completely understand what you are stating
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Wednesday, January 4, 2017 at 3:35:53 PM UTC+13, Erik wrote: > On 04/01/17 02:24, Callum Robinson wrote: > > On Wednesday, January 4, 2017 at 3:05:48 PM UTC+13, MRAB wrote: > >> What values can 'is_same' return? > >> > >> Which of those values are you checking for in the loop? > > > > I'm sorry but i do not completely understand what you are stating > > You need to think about the specific things (their type, their exact > values) that your functions might return. Printing some trace output is > a classic way of debugging your program. If, after this line: > > >>>> higher_or_lower = is_same(computer_number, guess) > > ... you added: > > print (higher_or_lower) > > ... what values do you then see being output? How will those values be > processed by the conditions you see that work on the "higher_or_lower" > variable? > > E. I did it and this is what it states when i run it hello. I have thought of a number between 1 and 100. Can you guess it? 5 Low Sorry , you are too high. Try again. Does this mean the number i entered is to low but the code is still stating it is to high? -- https://mail.python.org/mailman/listinfo/python-list
