Hi all,

I would like to improve my python program that takes a positive integer as its input and spits out its divisors, and the following code will do the work.

```
n = int(input("Write an positive integer :"))
divisors = []
for i in list(range(1,n+1)):
if n % i == 0:
divisors = divisors + [i]
print(divisors)
```

Here, I would like to know why “range(1,n+1)” instead of “range(1,n)”. I checked “range(1,n)” outputs only {1,2,…,n-1}, so I replaced it with n+1.

Also, I would like to improve my code so that if your input is **not** a positive integer, then machine will ask you to input a number again.

An ideal result of the code will be like this;

Write a positive integer: 0 ; Here you input 0 which is not a positive integer, so machine will ask again.

Write a positive integer: -58 ; Again, it is not positive.

write a positive integer: 24 ; It is a positive integer, so machine will give you the result.

[1, 2, 3, 4, 6, 8, 12, 24]

Any suggestion would be greatly appreciated.

Thanks.