Re: [Tutor] issues running python

2019-03-26 Thread Alan Gauld via Tutor
On 26/03/2019 21:41, Drew Jakala wrote:
> Hello,
> I'm having issues running python and sublime on my computer. Every time I
> try to run either one I get an error message that looks something like this:
>  "Traceback (most recent call last):
>   File "", line 1, in 
> python
> NameError: name 'python' is not defined
> I think I need to edit my path but I'm not sure how to do that correctly so
> any help would be greatly appreciated.

I know nothing about Sublime but it might help if you tell us what OS
you use and how exactly you try to run sublime.

The error you show us is coming from python itself so it looks like you
are trying to run python from inside python.

I suspect you may be following some kind of tutorial or help page
that says you should type something like:

python foo.py

This means from the OS pronpt you should type the line given.
But you are trying to type it at a python interpreter prompt.
The OS prompt usually looks like:

C:\WINDOWS>

or

user@host$

or similar.

The Python prompt usually looks like

>>>

You only type "python" at the OS prompt.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] issues running python

2019-03-26 Thread Drew Jakala
Hello,
I'm having issues running python and sublime on my computer. Every time I
try to run either one I get an error message that looks something like this:
 "Traceback (most recent call last):
  File "", line 1, in 
python
NameError: name 'python' is not defined
I think I need to edit my path but I'm not sure how to do that correctly so
any help would be greatly appreciated.

Thanks,
Drew


Virus-free.
www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2019-03-26 Thread Matthew Herzog
 elif fileDate = datetime.strptime(name[0:8], DATEFMT).date():
   ^
SyntaxError: invalid syntax



On Sat, Mar 23, 2019 at 6:43 PM Mats Wichmann  wrote:

> On 3/23/19 3:16 AM, Peter Otten wrote:
>
> > Personally I would use a try...except clause because with that you can
> > handle invalid dates like _etc.xls gracefully. So
> >
> > ERASED = "erased_"
> >
> >
> > def strip_prefix(name):
> > if name.startswith(ERASED):
> > name = name[len(ERASED):]
> > return name
> >
> >
> > def extract_date(name):
> > datestr = strip_prefix(name)[:8]
> > return datetime.datetime.strptime(datestr, DATEFMT).date()
> >
> >
> > for name in ...:
> > try:
> > file_date = extract_date(name)
> > except ValueError:
> > pass
> > else:
> > print(file_date)
>
> I'd endorse this approach as well.. with a DATEFMT of "%Y%m%d", you will
> get a ValueError for every date string that is not a valid date... which
> you then just ignore (the "pass"), since that's what you wanted to do.
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


-- 
The plural of anecdote is not "data."
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2019-03-26 Thread Mats Wichmann
On 3/26/19 12:26 PM, Matthew Herzog wrote:
> elif fileDate = datetime.strptime(name[0:8], DATEFMT).date():
>                    ^
> SyntaxError: invalid syntax

are you assigning (=) or comparing (==)?

you can't do both in one statement because of the side effect implications.

[except that starting with Python 3.8 you will be able to (see PEP 572),
but that will be a brand new operator,  := ]


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to store scores of a race's players

2019-03-26 Thread Bob Gailer
Please do not use a mangled return email address. It causes us a lot of
pain when we fail to read your address to fix it and get the message
bounced back. The only reason I'm even bothering to resend it is because I
put a lot of work into it.:
> On
> Mar 26, 2019 6:55 AM, "^Bart"  wrote:
> >
> > Hello!
> >
> > I need to store scores of three players for more than a race, after
every race the user will read "Is the competition finished?", if the
competition if finished the user will see the winner who got higest score:
> >
> Thank you for reaching out to us for help as You Learn Python. A good
mailing list to use instead of the main python list is tutor@python.org.
I'm including that list in the reply addresses; please use that address in
the future and always reply all so a copy goes to that list.
>
> This looks like a homework assignment. Be advised we won't write code for
you but we will help you when you get stuck and provide some guidance. I'm
personally curious as to who wrote that specification, since it is not well
written. One of the questions that fails to address is what if two or more
players have the same high score?
>
> It's also a little hard to guide you since we don't know what you've
already learned. One of the fundamental concepts in computer programming is
that of a loop. Since the requirements indicate there will be more than one
race that requires a loop. The simplest python construction for a loop is a
while. Within that Loop you write the code once rather than rewriting it as
you have done. I hope that is enough to get you started. Please apply that
advice as best you can and come back with a revised program.
>
> > p1 = int (input ("Insert score of the first player: "))
> > p2 = int (input ("Insert score of the second player: "))
> > p3 = int (input ("Insert score of the third player: "))
> >
> > race = str (input ("Is the competition finished?"))
> >
> > totalp1 = 0
> > totalp2 = 0
> > totalp3 = 0
> >
> > winner = 0
> >
> > if p1 > p2 and p1 > p3:
> > winner = c1
> > elif p2 > p1 and p2 > p3:
> > winner = p2
> > else:
> > winner = p3
> >
> > if "yes" in race:
> > print("The winner is:",winner)
> > else:
> > p1 = int (input ("Insert score of the first player: "))
> > p2 = int (input ("Insert score of the second player: "))
> > p3 = int (input ("Insert score of the third player: "))
> >
> > race = str (input ("Is the competition finished?"))
> >
> > You read above just my toughts, is there someone who could help me to
understand how to solve it?
> >
> > Regards.
> > ^Bart
> > --
> > https://mail.python.org/mailman/listinfo/python-list
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to store scores of a race's players

2019-03-26 Thread Bob Gailer
On Mar 26, 2019 6:55 AM, "^Bart"  wrote:
>
> Hello!
>
> I need to store scores of three players for more than a race, after every
race the user will read "Is the competition finished?", if the competition
if finished the user will see the winner who got higest score:
>
Thank you for reaching out to us for help as You Learn Python. A good
mailing list to use instead of the main python list is tutor@python.org.
I'm including that list in the reply addresses; please use that address in
the future and always reply all so a copy goes to that list.

This looks like a homework assignment. Be advised we won't write code for
you but we will help you when you get stuck and provide some guidance. I'm
personally curious as to who wrote that specification, since it is not well
written. One of the questions that fails to address is what if two or more
players have the same high score?

It's also a little hard to guide you since we don't know what you've
already learned. One of the fundamental concepts in computer programming is
that of a loop. Since the requirements indicate there will be more than one
race that requires a loop. The simplest python construction for a loop is a
while. Within that Loop you write the code once rather than rewriting it as
you have done. I hope that is enough to get you started. Please apply that
advice as best you can and come back with a revised program.

> p1 = int (input ("Insert score of the first player: "))
> p2 = int (input ("Insert score of the second player: "))
> p3 = int (input ("Insert score of the third player: "))
>
> race = str (input ("Is the competition finished?"))
>
> totalp1 = 0
> totalp2 = 0
> totalp3 = 0
>
> winner = 0
>
> if p1 > p2 and p1 > p3:
> winner = c1
> elif p2 > p1 and p2 > p3:
> winner = p2
> else:
> winner = p3
>
> if "yes" in race:
> print("The winner is:",winner)
> else:
> p1 = int (input ("Insert score of the first player: "))
> p2 = int (input ("Insert score of the second player: "))
> p3 = int (input ("Insert score of the third player: "))
>
> race = str (input ("Is the competition finished?"))
>
> You read above just my toughts, is there someone who could help me to
understand how to solve it?
>
> Regards.
> ^Bart
> --
> https://mail.python.org/mailman/listinfo/python-list
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor