import sys
arg = sys.argv[1]
arg_length = len(sys.argv[1])
print("arg_length: ",arg_length)
def palindrome(arg, arg_length):
for i in range(0,int(arg_length/2)): # for checking half string
if arg[i] != arg[arg_length-i-1]:
return False
return True
print(palindrome(arg, arg_length))
Output:
[home@fedora ~]$ python3 palidrom.py 11211
arg_length: 5
True
[home@fedora ~]$ python3 palidrom.py noon
arg_length: 4
True
[home@fedora ~]$ python3 palidrom.py qwerty
arg_length: 6
False