[Tutor] python question

trypticon at SAFe-mail.net trypticon at SAFe-mail.net
Mon Dec 8 17:09:35 EST 2003


Hi,
   i have a simple question. here is the code:

import string

num_str=raw_input('Enter a number:')

num_num=string.atoi(num_str)

fac_list=range(1,num_num+1)
print "BEFORE:", `fac_list`

i=0

while i < len(fac_list):
      if num_num % fac_list[i]==0:
              del fac_list[i]
       
       i=i+1
print "AFTER:", `fac_list`

there is a bug in this program. i know what the bug is(doesn't work correctly when you enter an even number), but i'm not sure how to solve it. Can anybody give me a few hints? Thanks!



More information about the Tutor mailing list