I have a problem with understanding of how to avoid #redundant repetition in for loops. This program intends to print the divisors of the number in the range 2 and number:
number = int(input('Enter an integer: '))
for divisor in range (2, number):
if number % divisor == 0:
print (divisor)
else:
print (number, 'has no divisors in the range')
Although it might look so basic for you pros but I am confused with avoiding redundancies.
Aucun commentaire:
Enregistrer un commentaire