[PyAR2] Mini Programming Challenge

Gordon Fisher phi3d at yahoo.com
Thu Oct 16 09:05:31 CEST 2008


That was a good excuse to write my first python program from scratch.  I learned a lot.
 
Here's what I came up with.
 
# ParseText.py
# Written on 10/16/2008 by Gordon Fisher
# Reads in keystrokes from the keyboard into a string.
# parses out how many times each letter appears in the string.
# Prints out the results.

keystrokes = []
letters = [0 for x in range (26)]
keystrokes = raw_input()
for x in range (len(keystrokes)):
    askey = ord(keystrokes[x])
    if askey > 64 and askey < 91: # lower case letters
        letters[askey-65] = letters[askey-65]+1
    elif askey > 96 and askey < 123: # upper case letters
            letters[askey-97] = letters[askey-97]+1
for x in range (26):
    print 'There are '+ str(letters[x])+' ' + chr(x + 65)+'\''+ 's'

 
Gordon Fisher
http://www.pointhappy.com/


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/pyar2/attachments/20081016/f992bde5/attachment.htm>


More information about the PyAR2 mailing list