This is the first time I have tried out functions (is that the main way of making subroutines in Python?)
Anyway, my function, mutate, below #make a child string by randomly changing one character of the parent Def mutate(): newnum=random.randrange(27) if newnum==0: gene=' ' else: gene=chr(newnum+96) position=random.randrange(len(target)) child=parent[:position-1]+gene+parent[position+1:] mutate() The trouble is when I later (as in further down the code) attempt to retrieve the value of gene I get an error saying that gene is undefined. It works fine when I don't have the routine defined as a function. - the IF- Else structure means gene must have a value of ' ' or 'a' to 'z'. It seems that the line: mutate() is not invoking the function, but why not? Thanks again - this group is great. I despair of ever being able to contribute though :-( -- http://mail.python.org/mailman/listinfo/python-list