Case-sensitivity: why -- or why not? (was Re: Damnation!)

Ben Cornett
Mon May 22 18:48:17 EDT 2000


On Mon, May 22, 2000 at 04:41:29PM -0600, Ivan Van Laningham wrote:
> Hi All--
> 
> Ben Cornett wrote:
> > 
> > this IS An exAmple oF WHat I meaNt WHEn I SAid "vOtIng DoesN'T HElP".
> > 
> 
> I bet you wrote a Python program to do this, didn't you?  Post the code!
> 
> <oPerAtOrs-ArE-stAndinG-bY>-lY y'RS,
> iVaN
> ----------------------------------------------
> Ivan Van Laningham
> Axent Technologies, Inc.
> http://www.pauahtun.org 
> http://www.foretec.com/python/workshops/1998-11/proceedings.html
> Army Signal Corps:  Cu Chi, Class of '70
> Author:  Teach Yourself Python in 24 Hours
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list


You caught me ;-)

I'm a python addict and I can't help myself.

######################################
#!/usr/bin/env python

import sys
import string
import whrandom

for s in sys.stdin.readlines ():
    for l in s:

        if l in string.letters:
            if whrandom.randint (0,1):
                l = string.upper (l)
            else:
                l = string.lower (l)
        sys.stdout.write (l)
#######################################
Simple, but effective.

Best,

Ben







More information about the Python-list mailing list