The first function that I created was to verify that all ‘unique identifiers’ were valid.  To do so I simply compared my two lists.  By that I mean I used a for loop and compared the two lists.  The yellow highlighted sections are the variables that contain the lists of words/tokens from the text files, explained in the post from Monday.  The orange highlighted section, for those unfamiliar, is me running the function verifytoken() within the code.  
    

 

tokenlist = load_tokens()
usedtokenlist = load_usedtokens()

def verifytoken(tokenlist,usedtokenlist):
   for u in usedtokenlist:
       if u not in tokenlist:
           print "Token " + u + " is NOT valid."
       else:
           print "Token " + u + " is valid."

verifytoken(tokenlist,usedtokenlist)

 


My for loop starts be going through each token in the usedtokenlist, and then seeing if that token exists in the valid tokenlist.  If it’s not in the list, then my function prints that it’s NOT valid, otherwise it prints that it is valid.  Once that function runs I just have to visually check to see if any NOT’s show up.  Otherwise I’m good to go, of which I was.

My last function was to add up all the votes, and determine which name was the winner.  To do so I decided to collect the names together into a dictionary, where the key was the name and the value was the total amount of votes.  Here is my function:

 

pollresults = load_kickstarterpoll() 

def kickstarterresults(pollresults):
   finalresults = {}
   for k in pollresults:
       if k in finalresults:
           finalresults[k] += 1  
       else:
           finalresults[k] = 1
   return finalresults

print kickstarterresults(pollresults)

 


As above, the yellow highlighted section is the variable identifying the list of all names, thus designated pollresults.  The orange section is the activation and running of the function kickstarterresults().  In the beginning of my function I create a variable to house the dictionary results called finalresults.  The I use a for loop and if statement combination to process the names.  If the name is not already in the dictionary, then it is added as a key/value combination with the value equalling to 1.  Beyond that, if the key already exists in the dictionary, then I simply add one to the current value associated with that key.  Thus I collect and add up all name votes.  Once the process is complete I print my function results (as there weren’t a whole lot of names).  Then, as with the last set of results, I simply optically review it for the winner.  WHICH, the WINNER IS Betwixt!!

For anyone interested in participating in the Icon discussion forum, please visit and contribute.  I was thinking a worm-hole type idea, but we are open to ‘mostly’ anything.  Look forward to hearing from people.