Here is the code I have written. # Create main function. def main(): a = input('Please Enter a Number: ') # Ask user for input. number = int(a) x = 1 sum_of = 0 while number > x: if number % x == 0: sum_of = sum_of + x x += 1 if sum_of == number: print(number,'is a Perfect Number') elif sum_of < number: print(number,'is a Non-perfect Number')
main() Here is the problem I am having. The program works perfect but I need to add the following: # a) write a function, getDivisors(), that returns a list of all # of the positive divisors of a given number. for example - # result = getDivisors(24) # print(result) # would yield: "[ 1, 2, 3, 4, 6, 8, 12]" # b) write a program that uses your function to determine which # numbers between 1 and 10,000 are perfect. (answer: 6, 28, 496 # and 8128 are perfect!) I know that mystring needs to be added. I need help Thank you in advance
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor