(no subject)

Mike C. Fletcher mcfletch at rogers.com
Sat Oct 2 16:29:00 EDT 2004


Some pointers:

    * An even number divided by 2 gives a remainder of 0, an odd number
      divided by 2 gives a remainder of 1.
    * There are functions/operators that give you the remainder of a
      division of one number by another (hint, "modulo")
    * Indices into a string are just numbers

Alternates:

    * Look at the "range" function's parameters (think indices)
    * If you're using a later version of Python, look at the "stride"
      available in slices
    * Brute force (track on/off for each item) will work, but be rather ugly

Good luck,
Mike


Campbell Kwok wrote:

> Hi, I am trying to write a program for my school homework and I'm a 
> little stuck. The homework have to do with barcodes and I need to read 
> the barcode, then add up all the odd number positions(eg a barcode of 
> 123456789012, then the odd is 1,3,5,7,9,1) I do not know how to get 
> the odd number positions out of that str of numbers. Please help me
>
 
________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com




More information about the Python-list mailing list