Aug-21-2018, 12:26 AM
I did Python Practice Exercise 4 from here:
https://www.practicepython.org/solution/...tions.html
The resulting code is:
https://www.practicepython.org/solution/...tions.html
The resulting code is:
#!/usr/bin/env python3 #PracticePythonExercise04.py num = int(input("Enter a number to find divisors for: ")) #listRange = list(range(1,num)) listRange = list(range(1,num+1)) divisorList = [] for number in listRange: if num % number == 0: divisorList.append(number) print(divisorList)What I don't understand is why we need the +1 on line 7? Why won't the commented-out statement on line 6 work?