A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
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.
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:
If you see anything you’d like to change or update, please consider contributing.
Note: The solution shown above is the current solution in the Sample Programs repository as of Oct 11 2022 01:31:51. The solution was first committed on Oct 27 2021 22:08:36. As a result, documentation below may be outdated.
No ‘How to Implement the Solution’ section available. Please consider contributing.
No ‘How to Run the Solution’ section available. Please consider contributing.