[Python Wpg] QuickReference and "any" in no particular order

Sydney Weidman syd at plug.ca
Thu Oct 25 12:30:49 EDT 2007


I had to try something with "any", so here it is:

import random

def run():
    draw = sorted(random.sample(range(1,50),6))
    print "6-49 Draw: %s" % (draw,)
    mypicks = sorted(random.sample(range(1,50),6))
    print "My 6-49 Picks: %s" % (mypicks,)
    if any([pick in draw for pick in mypicks]):
        print "You have winning numbers!!\n\n"
        return True
    else:
        print "Sorry, try again...\n\n"
        return False

if __name__ == '__main__':

    if any([run() for i in range(0,10)]):
        print "You had some winners in the series"
    else:
        print "No winners in the series"

Also, I found the Python Quick Reference:

http://rgruet.free.fr/#QuickRef

Very handy!
 
See you all next month!

- Syd





More information about the Winnipeg mailing list