Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Exercise 4 from practicepython.org
- def IsInt(N):
- try:
- int(N)
- return True
- except ValueError:
- return False
- InputNumber = input('Please input an integer number: ')
- if(IsInt(InputNumber)):
- InputNumber = int(InputNumber)
- else:
- print('The value inputted is not an integer ({0}).'.format(InputNumber))
- quit()
- Divisors = [Divisor for Divisor in range(1,InputNumber//2+1) if InputNumber%Divisor==0]
- Divisors.append(InputNumber)
- print(Divisors)
Add Comment
Please, Sign In to add comment