On 23/10/2013 21:42, Mauricio Villamil wrote: > Hello, > > And thank you for any help. >
Welcome to the python-tutor mailinglist. Please use text emalis, not html. Your email program has lost all the indentation below, making your program really hard to follow. > I am writing a little prog. On this part I need to recursively (preferably) > write to a list a value only if it's less than 49, else do an operation to > make it less than 49, then check which is the next available spot on the > list and write there ... so pseudo code would be like: > > def getGM(seed): ## function > > Gnumbers = [5] ## list to write to > for i in Gnumbers: iterate from begining of list to write to it > if (result <= 49): > > result = math.floor(seed * 1.61803398875) ## find value lesser than 49 > place = int(len(Gnumbers)) ## fins how long is > the list so far > Gnumbers[i] = result ## place result > at spot in list > print ("this is place :", place) ## see length of > list > else: ## if number bigger than 49 then divide the number to make it > smaller and wrote > result = math.floor(seed / 1.61803398875) ## make number smaller > if (result <= 49):## if right size write to array > Gnumbers[i] = result > else: > getGM(result)## if not divide again ( this could be a dedicated function ? > > > So ..the biggie is knowing all any time which is the next available place > in the list to write to (we don't want to overwirte previous values .... > To write to the next place in a list, simply use append. Gnumbers.append(result) No clue what the code you posted is supposed to do. -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor