if randval > perc: EMPTY <= you don't need the lines like this, they don't do anything return EMPTY
And you can test for less-than-or-equal in one test elif randval <= perc: return PERSON
in fact since one of the tests has to be true you can just use else:
if randval > perc: return EMPTY else: return PERSON
Kent
Kooser, Ara S wrote:
Kent and Max. Thank you very much. It works fine now.
Ara
perc = raw_input("Please enter a threshold between 0-1. ") perc = float(perc)
def percolation(perc): randval = random.random() print randval PERSON, EMPTY = '*', '.' if randval > perc: EMPTY return EMPTY elif randval < perc: PERSON return PERSON elif randval == perc: PERSON return PERSON
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor