# produce2.py
# Written by Todd Wareham for CS 2500
"""
Given the names of various produce items as a command-line arguments, prints
 the recognition-status of each item (fruit/vegetable/unrecognized) and the
 final percentage of recognized produce items (out of all items).

This version uses range() to make indices for explicitly accessing list
 elements.
"""

import sys

numProduce = numNonProduce = 0

for i in range(1,len(sys.argv),1):
    food = sys.argv[i]
    if ((food == "apple") or
        (food == "orange") or
        (food == "banana")):
        print "Item #", i, "(", food, ") is a fruit"
	numProduce += 1
    elif ((food == "potato") or
          (food == "carrot")):
        print "Item #", i, "(", food, ") is a vegetable"
	numProduce += 1
    else:
        print "Item #", i, "(", food, ") is not recognized produce"
	numNonProduce += 1

print "Produce index: ",  \
      ((numProduce * 1.0) / (numProduce + numNonProduce)) * 100, "%"

