adspace
Is there anybody who knows how to create a palindrome program without using string functions just conditional statements?
Answer Posted / Dileep Kumar Singh
Creating a palindrome program using only conditional statements can be challenging, but it's possible with some clever coding. One approach is to compare each character in the input string from both ends and check if they are identical. The following code snippet demonstrates this concept:
```
def is_palindrome(n):
num = int(str(n)[::-1])
return n == num
# Test a few numbers to see if they're palindromes
print(is_palindrome(12321)) # True
print(is_palindrome(123456789)) # False
```
In this example, the function `is_palindrome()` checks if a given number `n` is palindromic by comparing it to its reverse (created using string slicing).
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
can you give me the solution of iiie
what is alternater & engine genral protection?
what are the different ripple removing circuit . which one is better and why
Anyone answer what is average cost for 1 meter GI pipe Hot dipping
plz send me l&t auestion papers. i have been called for written and interview industrial automation 2 yrs exper. send me on mail pal_deepak06@yahoo.com