People here are right: remove the "not". You want to keep adding blanks until the total length is zero mod 4. Then, at line 19 in the dpaste, change the loop to: for blank in range(amountofblanks). You shouldn't be subtracting one from the value there.
--Ned. http://nedbatchelder.com Marty Alchin wrote: > On Wed, Jul 16, 2008 at 11:46 AM, Joshua Jonah <[EMAIL PROTECTED]> wrote: > >> Yeah, but the point is to make the list exactly divisible, is there a >> better way to do this? I'm then taking the number of fields and dividing >> them by four, then outputting that number of items in each column. >> > > I apologize for not catching this when I looked at your code before, > but he's right about the "not" thing. Consider this: > > >>>> make_divisible_by_four(num): >>>> > ... while num % 4: > ... num += 1 > ... return num > >>>> make_divisible_by_four(8) >>>> > 8 > >>>> make_divisible_by_four(10) >>>> > 12 > >>>> make_divisible_by_four(33) >>>> > 36 > > Of course, you're welcome to go with Scott's suggestion of doing all > the math in one line, but it loses a bit readability going that way. > On the flip side, it probably executes slightly faster, but probably > not enough to make much different in the real world. > > -Gul > > > > > -- Ned Batchelder, http://nedbatchelder.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---