Palindromic Number in Python (original) (raw)
Published on 27 October 2021 (Updated: 11 October 2022)
Welcome to the Palindromic Number in Python page! Here, you'll find the source code for this program as well as a description of how the program works.
Current Solution
import sys
def palindromic_number(x):
if x >= 0:
reversed_number = 0
noofdigits = 0
temp = x
while (temp > 0):
noofdigits += 1
reversed_number = (reversed_number * 10) + (temp % 10)
temp = int(temp/10)
if x == reversed_number:
print("true")
else:
print("false")
else:
print("Usage: please input a non-negative integer")
def main():
try:
palindromic_number(int(sys.argv[1]))
except (IndexError, ValueError):
print("Usage: please input a non-negative integer")
sys.exit(1)
if __name__ == "__main__":
main()
Palindromic Number in Python was written by:
- Jeremy Grifski
- manasmithamn
If you see anything you'd like to change or update, please consider contributing.
How to Implement the Solution
No 'How to Implement the Solution' section available. Please consider contributing.
How to Run the Solution
No 'How to Run the Solution' section available. Please consider contributing.