39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
import argparse
|
|
from transform.Transform import Transform
|
|
|
|
|
|
def parse_args():
|
|
'''
|
|
Argument Parser for terminal usage.
|
|
'''
|
|
parser = argparse.ArgumentParser(description=('Throw in an integer N to'
|
|
'transform it into a'
|
|
'palindrome'))
|
|
parser.add_argument('-i',
|
|
'--int',
|
|
required=True,
|
|
help='The integer to be transformed.',
|
|
type=int)
|
|
# NOTE: The argument must be an integer. Because of this constrain integers
|
|
# with leading zeroes will be stripped automatically in python 3.
|
|
args = parser.parse_args()
|
|
return args
|
|
|
|
|
|
def main():
|
|
args = parse_args()
|
|
if args.int <= 10000 and args.int > 0:
|
|
print('Input integer is: {}'.format(args.int))
|
|
transform = Transform()
|
|
palindrome = transform.palindrome(args.int)
|
|
print("Final Output is:", palindrome)
|
|
return palindrome
|
|
else:
|
|
print("Input integer is not betweent 1 and 10000")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|