[Tutor] Is there an easily or shorter way?

2014-12-15 Thread Ken G.
I am sure there is a better way to refine the following lines. Letting x equal a number from 1 to 28, go through 28 separate 'if' statements to print a resulting value that equaled the value of x. For example: x = 8 if x = 1, print 'one' if x = 2, print 'two' ... ... if x = 8, print 'eight' ..

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Ken G.
On 12/15/2014 04:45 PM, Danny Yoo wrote: As a side note: if we were to talk about how we'd do this in a professional context, I think we'd recommend a library such as "humanize", which has functions to go from numbers to human-friendly string descriptions. https://pypi.python.org/pypi/huma

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Ken G.
On 12/15/2014 05:49 PM, Steven D'Aprano wrote: On Mon, Dec 15, 2014 at 04:25:42PM -0500, Ken G. wrote: I am sure there is a better way to refine the following lines. Letting x equal a number from 1 to 28, go through 28 separate 'if' statements to print a resulting value that eq

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Ken G.
On 12/15/2014 05:59 PM, Dave Angel wrote: On 12/15/2014 04:25 PM, Ken G. wrote: I am sure there is a better way to refine the following lines. Letting x equal a number from 1 to 28, go through 28 separate 'if' statements to print a resulting value that equaled the value of x. For e

[Tutor] RESOLVED: Re: Is there an easily or shorter way?

2014-12-16 Thread Ken G.
On 12/15/2014 07:47 PM, Danny Yoo wrote: Thank you but actually whatever number I get from either 1 to 28, each number represent a property name such as "Reading Railroad", "Judy Avenue", "Pacific Gas and Electric", etc., etc. For example: if x = 1 then print "Mediterranean Avenue" if x = 2 th

[Tutor] Popen was deprecated since Python 2.6, now what?

2015-02-16 Thread Ken G.
Wow, just found out this morning that the following terms of: import os pr = os.popen("lpr", "w") pr.write(month), pr.write(" "), pr.write("\t\tLine ") was deprecated. In place there of, there is a subprocess to use. I have not been able to figure out on how to use a subprocess in place of my f

Re: [Tutor] Popen was deprecated since Python 2.6, now what?

2015-02-16 Thread Ken G.
On 02/16/2015 05:11 PM, Danny Yoo wrote: On Mon, Feb 16, 2015 at 1:26 PM, Ken G. wrote: Wow, just found out this morning that the following terms of: import os pr = os.popen("lpr", "w") pr.write(month), pr.write(" "), pr.write("\t\tLine ") was d

Re: [Tutor] Popen was deprecated since Python 2.6, now what?

2015-02-16 Thread Ken G.
On 02/16/2015 06:26 PM, Alan Gauld wrote: On 16/02/15 21:26, Ken G. wrote: I have not been able to figure out on how to use a subprocess in place of my former popen. I have been reading the new materials on the subprocess all day and it is still not quite understandable. Here is what the

[Tutor] Old popen turned in subprocess...[SOLVED]

2015-02-17 Thread Ken G.
I wish to thanks Danny Yoo and Alan Gauld for providing information on using the new subprocess in printing on paper, replacing my old popen which was deprecated since Python 2.6. After some trial and errors, I got my desired output printed. Not looking forward to updating my old programs. Thank

[Tutor] Rearranging a list

2015-02-26 Thread Ken G.
Assuming I have the following list and code how do I best be able rearrange the list as stated below: list = [0, 0, 21, 35, 19, 42] Using print list[2:6] resulted in the following: 221 335 419 542 I would like to rearrange the list as follow: 542 335 221 419

Re: [Tutor] Rearranging a list

2015-02-26 Thread Ken G.
I may have mis-stated my intention. I will rewrite my request for assistance later and resubmit. Thanks, Ken On 02/26/2015 08:04 AM, Peter Otten wrote: Steven D'Aprano wrote: Ah wait, the penny drops! Now I understand what you mean! Glad I'm not the only one ;)

[Tutor] Rearranging a list of numbers with corresponding index

2015-03-13 Thread Ken G.
I have been keeping track of numbers drawn in our local lotto drawings into a list format as shown in a short example below. Using such list, I am able to determine how often a number appears within the last 100 plus drawings. The length of my lists range from 5, 15, 35, 59and 75 long. I will

Re: [Tutor] Rearranging a list of numbers with corresponding index

2015-03-13 Thread Ken G.
On 03/13/2015 10:21 AM, Peter Otten wrote: Ken G. wrote: I have been keeping track of numbers drawn in our local lotto drawings into a list format as shown in a short example below. Using such list, I am able to determine how often a number appears within the last 100 plus drawings. The

Re: [Tutor] Rearranging a list of numbers with corresponding index (RESOLVED)

2015-03-13 Thread Ken G.
On 03/13/2015 10:38 AM, Dave Angel wrote: On 03/13/2015 09:57 AM, Ken G. wrote: I have been keeping track of numbers drawn in our local lotto drawings into a list format as shown in a short example below. Using such list, I am able to determine how often a number appears within the last 100

[Tutor] Function not returning 05 as string

2015-04-13 Thread Ken G.
I am sure there is an simple explanation but when I input 5 (as integer), resulting in 05 (as string), I get zero as the end result. When running the code: START OF PROGRAM: Enter the 1st number: 5 05 0 END OF PROGRAM: START OF CODE: import sys def numberentry(): print number01 = raw

Re: [Tutor] Function not returning 05 as string

2015-04-13 Thread Ken G.
On 04/13/2015 08:18 AM, Dave Angel wrote: On 04/13/2015 08:11 AM, Ken G. wrote: I am sure there is an simple explanation but when I input 5 (as integer), resulting in 05 (as string), I get zero as the end result. When running the code: START OF PROGRAM: Enter the 1st number: 5 05 0 END OF

Re: [Tutor] Function not returning 05 as string [SOLVED]

2015-04-13 Thread Ken G.
On 04/13/2015 08:56 AM, Steven D'Aprano wrote: On Mon, Apr 13, 2015 at 08:11:46AM -0400, Ken G. wrote: I am sure there is an simple explanation but when I input 5 (as integer), resulting in 05 (as string), I get zero as the end result. When running the code: number01 = 0 Here you se

[Tutor] Changing a string number to another number

2015-04-15 Thread Ken G.
When running the following code, I get the following error code: 201504110102030405061 Traceback (most recent call last): File "Mega_Millions_Tickets_Change.py", line 11, in datecode[20:21] = "0" TypeError: 'str' object does not support item assignment datecode = "201504110102030405061"

Re: [Tutor] Changing a string number to another number [RESOLVED]

2015-04-15 Thread Ken G.
On 04/15/2015 08:36 AM, Dave Angel wrote: On 04/15/2015 08:21 AM, Ken G. wrote: When running the following code, I get the following error code: 201504110102030405061 Traceback (most recent call last): File "Mega_Millions_Tickets_Change.py", line 11, in datecode[2

Re: [Tutor] Changing a string number to another number [RESOLVED]

2015-04-15 Thread Ken G.
On 04/15/2015 08:50 AM, Peter Otten wrote: Ken G. wrote: When running the following code, I get the following error code: 201504110102030405061 Traceback (most recent call last): File "Mega_Millions_Tickets_Change.py", line 11, in datecode[20:21] = "0" Typ

Re: [Tutor] Changing a string number to another number [RESOLVED]

2015-04-15 Thread Ken G.
On 04/15/2015 09:09 AM, Steven D'Aprano wrote: On Wed, Apr 15, 2015 at 08:21:33AM -0400, Ken G. wrote: When running the following code, I get the following error code: 201504110102030405061 Traceback (most recent call last): File "Mega_Millions_Tickets_Change.py&quo

[Tutor] Reference last email message...

2015-04-15 Thread Ken G.
I just emailed that I was unable to correct a message in ModTools so I went to Yahoo and made the change and then approved it. Noticing it did not appear on the list, I checked the Activity Log in Yahoo and it was marked Bounced! Several days ago, we had another message correction and that too,

Re: [Tutor] Reference last email message...

2015-04-16 Thread Ken G.
On 04/15/2015 08:45 PM, Dave Angel wrote: On 04/15/2015 07:47 PM, Ken G. wrote: I just emailed that I was unable to correct a message in ModTools so I went to Yahoo and made the change and then approved it. Noticing it did not appear on the list, I checked the Activity Log in Yahoo and it

Re: [Tutor] Reference last email message...

2015-04-16 Thread Ken G.
On 04/15/2015 08:21 PM, Alan Gauld wrote: On 16/04/15 00:47, Ken G. wrote: I just emailed that I was unable to correct a message in ModTools so I went to Yahoo and made the change and then approved it. What is ModTools? What kind of message? Where does Yahoo fit in? What does any of it

<    1   2