Re: [Tutor] Splitting a number into even- and odd- numbered digits

2006-04-20 Thread Carroll, Barry
Greetings: Unfortunately, my problem description was incomplete. I forgot to include two important requirements: 1. the length of the input string is arbitrary, 2. the order of the digits must be maintained. I could not find a way to include these requirements in a single, simple expres

Re: [Tutor] Splitting a number into even- and odd- numbered digits

2006-04-20 Thread Carroll, Barry
Greetings: First of all, thanks to those who contributed suggestions. Unfortunately, my description was incomplete. > I am writing a function that accepts a string of decimal digits, > calculates a checksum and returns it as a single character string. > The first step in the calculation is to

Re: [Tutor] Splitting a number into even- and odd- numbered digits

2006-04-20 Thread Python
On Wed, 2006-04-19 at 17:17 -0700, Carroll, Barry wrote: > Greetings: > > I am writing a function that accepts a string of decimal digits, > calculates a checksum and returns it as a single character string. > The first step in the calculation is to split the input into two > strings: the even-

Re: [Tutor] Splitting a number into even- and odd- numbered digits

2006-04-19 Thread John Fouhy
On 20/04/06, Carroll, Barry <[EMAIL PROTECTED]> wrote: > The following code fragment does the job but seems sort of brutish and > inelegant to me: > > >>> > >>> s = '987654321' > >>> odd = '' > >>> for c in s[::-2]: > ... odd = c + odd > ... > >>> String slicing will actually produce stri