All pastes #2077021 Raw Edit

foobaz

public python v1 · immutable
#2077021 ·published 2011-06-09 00:18 UTC
rendered paste body
#!/usr/bin/env pythondef hoppity(puzzle):    """ Takes a filename argument for each number in the text file    and returns Hoppity, Hophop or Hop depending on the ability    if the number is divided by 3,5 or both of them """    handler = open(puzzle)    read_all = handler.read().splitlines()    try:        for num in range(1,int(read_all[0])+1):            if num == "":                read_all.remove(num)            else:                num = int(num)                print num                if num % 3 == 0 and num % 5 == 0:                    print "Hop\n"                elif num % 3 == 0:                    print "Hoppity\n"                elif num % 5 == 0:                    print "Hophop\n"    finally:        handler.close()if __name__ == "__main__":    import sys    hoppity(sys.argv[1])