Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
bird [2008/01/17 08:56]
jtk
bird [2008/01/17 08:57]
jtk
Line 1: Line 1:
-//A slight variation of what was given in class.//+//A slight variation of what was given in class...//
 <​html><​pre>​ <​html><​pre>​
 import string import string
Line 35: Line 35:
 import string import string
  
-def main(bird): +def main(search): 
-    ​cTotal ​= 0 +    ​total = 0 
-    ​cBirds ​= 0+    ​= 0
     ​     ​
     infile = open("​birdlist48.csv"​)     infile = open("​birdlist48.csv"​)
Line 46: Line 46:
         # print line         # print line
         fields = string.split(line,​ ","​)         fields = string.split(line,​ ","​)
-        # print fields 
         if fields[0]:         if fields[0]:
-            order = fields[0] +            order = string.capwords(fields[0]) 
-        ​# family ​= fields[1+        ​name = fields[6
-        if fields[6]+        if name: 
-            ​cTotal ​cTotal ​+ 1+            total = total + 1 
 +        if name and string.find(string.lower(name),​ search) >= 0
 +            ​+ 1
             genus = fields[4]             genus = fields[4]
             species = fields[5]             species = fields[5]
-            ​name = fields[6] +            print "%-30s (%s %s, order %s)" % (name, genus, species, order) 
-            if string.lower(name).find(bird) >= 0: +    print "%d birds, ​of which %d match %s" ​% (total, ​csearch)
-                cBirds = cBirds + 1 +
-                ​print "%-30s (%s %s, order %s)" % (name, genus, species, ​string.capwords(order)+
-    print "total birds ="cTotal +
-    print "total"bird"​=",​ cBirds+
     ​     ​
-main("sparrow")+main("hawk")
 </​pre></​html>​ </​pre></​html>​
  
 
bird.txt · Last modified: 2008/01/17 08:57 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki