palindrome/palindrome.py

39 lines
1.2 KiB
Python
Raw Normal View History

2021-03-17 09:32:45 +00:00
#!/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)
2021-03-17 11:37:54 +00:00
# NOTE: The argument must be an integer. Because of this constrain integers
# with leading zeroes will be stripped automatically in python 3.
2021-03-17 09:32:45 +00:00
args = parser.parse_args()
return args
def main():
args = parse_args()
2021-03-17 11:37:54 +00:00
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")
2021-03-17 09:32:45 +00:00
if __name__ == '__main__':
main()