0

So I tried making my first program but it didn't work, but I can't figure out what is wrong with it. I have added some commentary with the code:

```
#!/usr/bin/env python
import sys
from random import randrange, shuffle, choice, sample
DOORS = ['ant','ant','ant','bee','bee','bee','car','car']
def pickdoor(picked):
"""Returns a number representing the original door chosen"""
return randrange(8)
def revealants(revealed1):
"""randomly reveals 1 door containing ants (cannot be the original)"""
alldoors = set([0,1,2,3,4,5,6,7])
doorswithants = [i for (i,v) in enumerate(DOORS) if v == 'ant']
originaldoor = set([picked])
availabledoors1 = list(doorswithants - originaldoor)
return choice(availabledoors2)
def revealbees(revealed2):
"""ramdomly reveals 1 door containing bees (cannot be the original)"""
doorswithbees = [i for (i,v) in enumerate(DOORS) if v == 'bee']
availabledoors2 = list(doorswithbees - originaldoor)
return choice(doorswithbees)
def revealcars(revealed3):
"""randomly reveals 1 door containing cars (cannot be original)"""
doorswithcars = [i for (i,v) in enumerate(DOORS) if v == 'car']
availabledoors3 = list(doorswithcars - originaldoor)
return choice(doorswithcars)
def switch(switched):
"""randomly chooses a door that is not the original door and that has not been revealed"""
availabledoors4 = list(alldoors - originaldoor - revealed1 - revealed2 - revaled3)
return choice(availabledoors4)
def main(iterations=10000):
shuffle(DOORS)
obtainedant = 0
obtainedbee = 0
obtainedcar = 0
for dummy in xrange(iterations):
"""calculates the chance of the final switched door containing an ant/bee/car"""
if switch == 'ant':
obtainedant += 1
if switch == 'bee':
obtainedbee += 1
if switch == 'car':
obtainedcar += 1
chanceofgettingant = (float(obtainedant) / iterations) * 100
chanceofgettingbee = (float(obtainedbee) / iterations) * 100
chanceofgettingcar = (float(obtainedcar) / iterations) * 100
print "Chance of getting ant: %f%%" % chanceofgettingant
print "Chance of getting bee: %f%%" % chanceofgettingbee
print "Chance of getting car: %f%%" % chanceofgettingcar
if __name__ == "__main__":
if len(sys.argv) == 2:
main(int(sys.argv[1]))
else:
main()
```

Running the program currently gets me 0% for everything. Help would be much appreciated :)